Skip to content

Commit c4c2009

Browse files
committed
Merge pull request #92141 from SatLess/Anim-Player-Pos-Double-Click
Allow double-click within tracks to set a new play position
2 parents f1ba8ee + e64206d commit c4c2009

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

editor/animation_bezier_editor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,13 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
11411141
}
11421142

11431143
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
1144+
Point2 pos = mb->get_position();
1145+
bool no_mod_key_pressed = !mb->is_alt_pressed() && !mb->is_shift_pressed() && !mb->is_command_or_control_pressed();
1146+
if (mb->is_double_click() && !moving_selection && no_mod_key_pressed) {
1147+
int x = pos.x - timeline->get_name_limit();
1148+
float ofs = x / timeline->get_zoom_scale() + timeline->get_value();
1149+
emit_signal(SNAME("timeline_changed"), ofs, false);
1150+
}
11441151
for (const KeyValue<int, Rect2> &E : subtracks) {
11451152
if (E.value.has_point(mb->get_position())) {
11461153
if (!locked_tracks.has(E.key) && !hidden_tracks.has(E.key)) {
@@ -2301,6 +2308,7 @@ void AnimationBezierTrackEdit::_bind_methods() {
23012308
ADD_SIGNAL(MethodInfo("select_key", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "single"), PropertyInfo(Variant::INT, "track")));
23022309
ADD_SIGNAL(MethodInfo("deselect_key", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::INT, "track")));
23032310
ADD_SIGNAL(MethodInfo("clear_selection"));
2311+
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "timeline_only")));
23042312
}
23052313

23062314
AnimationBezierTrackEdit::AnimationBezierTrackEdit() {

editor/animation_track_editor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,6 +3009,12 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
30093009
Ref<InputEventMouseButton> mb = p_event;
30103010
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
30113011
Point2 pos = mb->get_position();
3012+
bool no_mod_key_pressed = !mb->is_alt_pressed() && !mb->is_shift_pressed() && !mb->is_command_or_control_pressed();
3013+
if (mb->is_double_click() && !moving_selection && no_mod_key_pressed) {
3014+
int x = pos.x - timeline->get_name_limit();
3015+
float ofs = x / timeline->get_zoom_scale() + timeline->get_value();
3016+
emit_signal(SNAME("timeline_changed"), ofs, false);
3017+
}
30123018

30133019
if (!read_only) {
30143020
if (check_rect.has_point(pos)) {
@@ -7755,6 +7761,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
77557761
bezier_edit->set_timeline(timeline);
77567762
bezier_edit->hide();
77577763
bezier_edit->set_v_size_flags(SIZE_EXPAND_FILL);
7764+
bezier_edit->connect("timeline_changed", callable_mp(this, &AnimationTrackEditor::_timeline_changed));
77587765

77597766
timeline_vbox->set_custom_minimum_size(Size2(0, 150) * EDSCALE);
77607767

0 commit comments

Comments
 (0)