Skip to content

Commit e64206d

Browse files
SatSatLess
authored andcommitted
Allow double-click within tracks to set a new play position
1 parent 8f78e75 commit e64206d

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
@@ -2985,6 +2985,12 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
29852985
Ref<InputEventMouseButton> mb = p_event;
29862986
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
29872987
Point2 pos = mb->get_position();
2988+
bool no_mod_key_pressed = !mb->is_alt_pressed() && !mb->is_shift_pressed() && !mb->is_command_or_control_pressed();
2989+
if (mb->is_double_click() && !moving_selection && no_mod_key_pressed) {
2990+
int x = pos.x - timeline->get_name_limit();
2991+
float ofs = x / timeline->get_zoom_scale() + timeline->get_value();
2992+
emit_signal(SNAME("timeline_changed"), ofs, false);
2993+
}
29882994

29892995
if (!read_only) {
29902996
if (check_rect.has_point(pos)) {
@@ -7657,6 +7663,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
76577663
bezier_edit->set_timeline(timeline);
76587664
bezier_edit->hide();
76597665
bezier_edit->set_v_size_flags(SIZE_EXPAND_FILL);
7666+
bezier_edit->connect("timeline_changed", callable_mp(this, &AnimationTrackEditor::_timeline_changed));
76607667

76617668
timeline_vbox->set_custom_minimum_size(Size2(0, 150) * EDSCALE);
76627669

0 commit comments

Comments
 (0)