1/**************************************************************************/
2/* animation_track_editor.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef ANIMATION_TRACK_EDITOR_H
32#define ANIMATION_TRACK_EDITOR_H
33
34#include "editor/editor_data.h"
35#include "editor/editor_properties.h"
36#include "editor/property_selector.h"
37#include "scene/3d/node_3d.h"
38#include "scene/gui/control.h"
39#include "scene/gui/menu_button.h"
40#include "scene/gui/scroll_bar.h"
41#include "scene/gui/tree.h"
42#include "scene/resources/animation.h"
43
44class AnimationTrackEditor;
45class AnimationTrackEdit;
46class CheckBox;
47class EditorSpinSlider;
48class HSlider;
49class OptionButton;
50class PanelContainer;
51class SceneTreeDialog;
52class SpinBox;
53class TextureRect;
54class ViewPanner;
55
56class AnimationTrackKeyEdit : public Object {
57 GDCLASS(AnimationTrackKeyEdit, Object);
58
59public:
60 bool setting = false;
61 bool animation_read_only = false;
62
63 Ref<Animation> animation;
64 int track = -1;
65 float key_ofs = 0;
66 Node *root_path = nullptr;
67
68 PropertyInfo hint;
69 NodePath base;
70 bool use_fps = false;
71
72 bool _hide_script_from_inspector() { return true; }
73 bool _hide_metadata_from_inspector() { return true; }
74 bool _dont_undo_redo() { return true; }
75
76 bool _is_read_only() { return animation_read_only; }
77
78 void notify_change();
79 Node *get_root_path();
80 void set_use_fps(bool p_enable);
81
82protected:
83 static void _bind_methods();
84 void _fix_node_path(Variant &value);
85 void _update_obj(const Ref<Animation> &p_anim);
86 void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to);
87 bool _set(const StringName &p_name, const Variant &p_value);
88 bool _get(const StringName &p_name, Variant &r_ret) const;
89 void _get_property_list(List<PropertyInfo> *p_list) const;
90};
91
92class AnimationMultiTrackKeyEdit : public Object {
93 GDCLASS(AnimationMultiTrackKeyEdit, Object);
94
95public:
96 bool setting = false;
97 bool animation_read_only = false;
98
99 Ref<Animation> animation;
100
101 RBMap<int, List<float>> key_ofs_map;
102 RBMap<int, NodePath> base_map;
103 PropertyInfo hint;
104
105 Node *root_path = nullptr;
106
107 bool use_fps = false;
108
109 bool _hide_script_from_inspector() { return true; }
110 bool _hide_metadata_from_inspector() { return true; }
111 bool _dont_undo_redo() { return true; }
112
113 bool _is_read_only() { return animation_read_only; }
114
115 void notify_change();
116 Node *get_root_path();
117 void set_use_fps(bool p_enable);
118
119protected:
120 static void _bind_methods();
121 void _fix_node_path(Variant &value, NodePath &base);
122 void _update_obj(const Ref<Animation> &p_anim);
123 void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to);
124 bool _set(const StringName &p_name, const Variant &p_value);
125 bool _get(const StringName &p_name, Variant &r_ret) const;
126 void _get_property_list(List<PropertyInfo> *p_list) const;
127};
128
129class AnimationTimelineEdit : public Range {
130 GDCLASS(AnimationTimelineEdit, Range);
131
132 Ref<Animation> animation;
133 bool read_only = false;
134
135 AnimationTrackEdit *track_edit = nullptr;
136 int name_limit = 0;
137 Range *zoom = nullptr;
138 Range *h_scroll = nullptr;
139 float play_position_pos = 0.0f;
140
141 HBoxContainer *len_hb = nullptr;
142 EditorSpinSlider *length = nullptr;
143 Button *loop = nullptr;
144 TextureRect *time_icon = nullptr;
145
146 MenuButton *add_track = nullptr;
147 Control *play_position = nullptr; //separate control used to draw so updates for only position changed are much faster
148 HScrollBar *hscroll = nullptr;
149
150 void _zoom_changed(double);
151 void _anim_length_changed(double p_new_len);
152 void _anim_loop_pressed();
153
154 void _play_position_draw();
155 Rect2 hsize_rect;
156
157 bool editing = false;
158 bool use_fps = false;
159
160 Ref<ViewPanner> panner;
161 void _pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event);
162 void _zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event);
163
164 bool dragging_timeline = false;
165 bool dragging_hsize = false;
166 float dragging_hsize_from = 0.0f;
167 float dragging_hsize_at = 0.0f;
168
169 virtual void gui_input(const Ref<InputEvent> &p_event) override;
170 void _track_added(int p_track);
171
172protected:
173 static void _bind_methods();
174 void _notification(int p_what);
175
176public:
177 int get_name_limit() const;
178 int get_buttons_width() const;
179
180 float get_zoom_scale() const;
181
182 virtual Size2 get_minimum_size() const override;
183 void set_animation(const Ref<Animation> &p_animation, bool p_read_only);
184 void set_track_edit(AnimationTrackEdit *p_track_edit);
185 void set_zoom(Range *p_zoom);
186 Range *get_zoom() const { return zoom; }
187
188 void set_play_position(float p_pos);
189 float get_play_position() const;
190 void update_play_position();
191
192 void update_values();
193
194 void set_use_fps(bool p_use_fps);
195 bool is_using_fps() const;
196
197 void set_hscroll(HScrollBar *p_hscroll);
198
199 virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
200
201 AnimationTimelineEdit();
202};
203
204class AnimationTrackEdit : public Control {
205 GDCLASS(AnimationTrackEdit, Control);
206 friend class AnimationTimelineEdit;
207
208 enum {
209 MENU_CALL_MODE_CONTINUOUS,
210 MENU_CALL_MODE_DISCRETE,
211 MENU_CALL_MODE_CAPTURE,
212 MENU_INTERPOLATION_NEAREST,
213 MENU_INTERPOLATION_LINEAR,
214 MENU_INTERPOLATION_CUBIC,
215 MENU_INTERPOLATION_LINEAR_ANGLE,
216 MENU_INTERPOLATION_CUBIC_ANGLE,
217 MENU_LOOP_WRAP,
218 MENU_LOOP_CLAMP,
219 MENU_KEY_INSERT,
220 MENU_KEY_DUPLICATE,
221 MENU_KEY_ADD_RESET,
222 MENU_KEY_DELETE,
223 MENU_USE_BLEND_ENABLED,
224 MENU_USE_BLEND_DISABLED,
225 };
226
227 AnimationTimelineEdit *timeline = nullptr;
228 Popup *path_popup = nullptr;
229 LineEdit *path = nullptr;
230 Node *root = nullptr;
231 Control *play_position = nullptr; //separate control used to draw so updates for only position changed are much faster
232 float play_position_pos = 0.0f;
233 NodePath node_path;
234
235 Ref<Animation> animation;
236 bool read_only = false;
237 int track = 0;
238
239 Rect2 check_rect;
240 Rect2 path_rect;
241
242 Rect2 update_mode_rect;
243 Rect2 interp_mode_rect;
244 Rect2 loop_wrap_rect;
245 Rect2 remove_rect;
246
247 Ref<Texture2D> type_icon;
248 Ref<Texture2D> selected_icon;
249
250 PopupMenu *menu = nullptr;
251
252 bool hovered = false;
253 bool clicking_on_name = false;
254 int hovering_key_idx = -1;
255
256 void _zoom_changed();
257
258 Ref<Texture2D> icon_cache;
259 String path_cache;
260
261 void _menu_selected(int p_index);
262
263 void _path_submitted(const String &p_text);
264 void _play_position_draw();
265 bool _is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const;
266
267 Ref<Texture2D> _get_key_type_icon() const;
268
269 mutable int dropping_at = 0;
270 float insert_at_pos = 0.0f;
271 bool moving_selection_attempt = false;
272 int select_single_attempt = -1;
273 bool moving_selection = false;
274 float moving_selection_from_ofs = 0.0f;
275
276 bool in_group = false;
277 AnimationTrackEditor *editor = nullptr;
278
279protected:
280 static void _bind_methods();
281 void _notification(int p_what);
282
283 virtual void gui_input(const Ref<InputEvent> &p_event) override;
284
285public:
286 virtual Variant get_drag_data(const Point2 &p_point) override;
287 virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
288 virtual void drop_data(const Point2 &p_point, const Variant &p_data) override;
289
290 virtual String get_tooltip(const Point2 &p_pos) const override;
291
292 virtual int get_key_height() const;
293 virtual Rect2 get_key_rect(int p_index, float p_pixels_sec);
294 virtual bool is_key_selectable_by_distance() const;
295 virtual void draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right);
296 virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right);
297 virtual void draw_bg(int p_clip_left, int p_clip_right);
298 virtual void draw_fg(int p_clip_left, int p_clip_right);
299
300 //helper
301 void draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region);
302 void draw_rect_clipped(const Rect2 &p_rect, const Color &p_color, bool p_filled = true);
303
304 int get_track() const;
305 Ref<Animation> get_animation() const;
306 AnimationTimelineEdit *get_timeline() const { return timeline; }
307 AnimationTrackEditor *get_editor() const { return editor; }
308 NodePath get_path() const;
309 void set_animation_and_track(const Ref<Animation> &p_animation, int p_track, bool p_read_only);
310 virtual Size2 get_minimum_size() const override;
311
312 void set_timeline(AnimationTimelineEdit *p_timeline);
313 void set_editor(AnimationTrackEditor *p_editor);
314 void set_root(Node *p_root);
315
316 void set_play_position(float p_pos);
317 void update_play_position();
318 void cancel_drop();
319
320 void set_in_group(bool p_enable);
321 void append_to_selection(const Rect2 &p_box, bool p_deselection);
322
323 AnimationTrackEdit();
324};
325
326class AnimationTrackEditPlugin : public RefCounted {
327 GDCLASS(AnimationTrackEditPlugin, RefCounted);
328
329public:
330 virtual AnimationTrackEdit *create_value_track_edit(Object *p_object, Variant::Type p_type, const String &p_property, PropertyHint p_hint, const String &p_hint_string, int p_usage);
331 virtual AnimationTrackEdit *create_audio_track_edit();
332 virtual AnimationTrackEdit *create_animation_track_edit(Object *p_object);
333};
334
335class AnimationTrackKeyEdit;
336class AnimationMultiTrackKeyEdit;
337class AnimationBezierTrackEdit;
338
339class AnimationTrackEditGroup : public Control {
340 GDCLASS(AnimationTrackEditGroup, Control);
341 Ref<Texture2D> icon;
342 String node_name;
343 NodePath node;
344 Node *root = nullptr;
345 AnimationTimelineEdit *timeline = nullptr;
346
347 void _zoom_changed();
348
349protected:
350 void _notification(int p_what);
351
352public:
353 void set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node);
354 virtual Size2 get_minimum_size() const override;
355 void set_timeline(AnimationTimelineEdit *p_timeline);
356 void set_root(Node *p_root);
357
358 AnimationTrackEditGroup();
359};
360
361class AnimationTrackEditor : public VBoxContainer {
362 GDCLASS(AnimationTrackEditor, VBoxContainer);
363 friend class AnimationTimelineEdit;
364
365 Ref<Animation> animation;
366 bool read_only = false;
367 Node *root = nullptr;
368
369 MenuButton *edit = nullptr;
370
371 PanelContainer *main_panel = nullptr;
372 HScrollBar *hscroll = nullptr;
373 ScrollContainer *scroll = nullptr;
374 VBoxContainer *track_vbox = nullptr;
375 AnimationBezierTrackEdit *bezier_edit = nullptr;
376
377 Label *info_message = nullptr;
378
379 AnimationTimelineEdit *timeline = nullptr;
380 HSlider *zoom = nullptr;
381 EditorSpinSlider *step = nullptr;
382 TextureRect *zoom_icon = nullptr;
383 Button *snap = nullptr;
384 Button *bezier_edit_icon = nullptr;
385 OptionButton *snap_mode = nullptr;
386
387 Button *imported_anim_warning = nullptr;
388 void _show_imported_anim_warning();
389
390 void _snap_mode_changed(int p_mode);
391 Vector<AnimationTrackEdit *> track_edits;
392 Vector<AnimationTrackEditGroup *> groups;
393
394 bool animation_changing_awaiting_update = false;
395 void _animation_update(); // Updated by AnimationTrackEditor(this)
396 int _get_track_selected();
397 void _animation_changed();
398 void _update_tracks();
399 void _redraw_tracks();
400 void _redraw_groups();
401 void _check_bezier_exist();
402
403 void _name_limit_changed();
404 void _timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only);
405 void _track_remove_request(int p_track);
406 void _animation_track_remove_request(int p_track, Ref<Animation> p_from_animation);
407 void _track_grab_focus(int p_track);
408
409 void _update_scroll(double);
410 void _update_step(double p_new_step);
411 void _update_length(double p_new_len);
412 void _dropped_track(int p_from_track, int p_to_track);
413
414 void _add_track(int p_type);
415 void _new_track_node_selected(NodePath p_path);
416 void _new_track_property_selected(String p_name);
417
418 void _update_step_spinbox();
419
420 PropertySelector *prop_selector = nullptr;
421 PropertySelector *method_selector = nullptr;
422 SceneTreeDialog *pick_track = nullptr;
423 int adding_track_type = 0;
424 NodePath adding_track_path;
425
426 bool keying = false;
427
428 struct InsertData {
429 Animation::TrackType type;
430 NodePath path;
431 int track_idx = 0;
432 Variant value;
433 String query;
434 bool advance = false;
435 };
436
437 Label *insert_confirm_text = nullptr;
438 CheckBox *insert_confirm_bezier = nullptr;
439 CheckBox *insert_confirm_reset = nullptr;
440 ConfirmationDialog *insert_confirm = nullptr;
441 bool insert_queue = false;
442 List<InsertData> insert_data;
443
444 void _query_insert(const InsertData &p_id);
445 Ref<Animation> _create_and_get_reset_animation();
446 void _confirm_insert_list();
447 struct TrackIndices {
448 int normal;
449 int reset;
450
451 TrackIndices(const Animation *p_anim = nullptr, const Animation *p_reset_anim = nullptr) {
452 normal = p_anim ? p_anim->get_track_count() : 0;
453 reset = p_reset_anim ? p_reset_anim->get_track_count() : 0;
454 }
455 };
456 TrackIndices _confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_reset_wanted, Ref<Animation> p_reset_anim, bool p_create_beziers);
457 void _insert_track(bool p_reset_wanted, bool p_create_beziers);
458
459 void _root_removed();
460
461 PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val = nullptr);
462
463 Ref<ViewPanner> panner;
464 void _pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event);
465 void _zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event);
466
467 void _timeline_value_changed(double);
468
469 float insert_key_from_track_call_ofs = 0.0f;
470 int insert_key_from_track_call_track = 0;
471 void _insert_key_from_track(float p_ofs, int p_track);
472 void _add_method_key(const String &p_method);
473
474 void _clear_selection_for_anim(const Ref<Animation> &p_anim);
475 void _select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos);
476
477 //selection
478
479 struct SelectedKey {
480 int track = 0;
481 int key = 0;
482 bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; };
483 };
484
485 struct KeyInfo {
486 float pos = 0;
487 };
488
489 RBMap<SelectedKey, KeyInfo> selection;
490
491 bool moving_selection = false;
492 float moving_selection_offset = 0.0f;
493 void _move_selection_begin();
494 void _move_selection(float p_offset);
495 void _move_selection_commit();
496 void _move_selection_cancel();
497
498 AnimationTrackKeyEdit *key_edit = nullptr;
499 AnimationMultiTrackKeyEdit *multi_key_edit = nullptr;
500 void _update_key_edit();
501 void _clear_key_edit();
502
503 Control *box_selection = nullptr;
504 void _box_selection_draw();
505 bool box_selecting = false;
506 Vector2 box_selecting_from;
507 Rect2 box_select_rect;
508 void _scroll_input(const Ref<InputEvent> &p_event);
509
510 Vector<Ref<AnimationTrackEditPlugin>> track_edit_plugins;
511
512 void _toggle_bezier_edit();
513 void _cancel_bezier_edit();
514 void _bezier_edit(int p_for_track);
515 void _bezier_track_set_key_handle_mode(Animation *p_anim, int p_track, int p_index, Animation::HandleMode p_mode, Animation::HandleSetMode p_set_mode = Animation::HANDLE_SET_MODE_NONE);
516
517 ////////////// edit menu stuff
518
519 ConfirmationDialog *bake_dialog = nullptr;
520 CheckBox *bake_trs = nullptr;
521 CheckBox *bake_blendshape = nullptr;
522 CheckBox *bake_value = nullptr;
523 SpinBox *bake_fps = nullptr;
524
525 ConfirmationDialog *optimize_dialog = nullptr;
526 SpinBox *optimize_velocity_error = nullptr;
527 SpinBox *optimize_angular_error = nullptr;
528 SpinBox *optimize_precision_error = nullptr;
529
530 ConfirmationDialog *cleanup_dialog = nullptr;
531 CheckBox *cleanup_keys = nullptr;
532 CheckBox *cleanup_tracks = nullptr;
533 CheckBox *cleanup_all = nullptr;
534
535 ConfirmationDialog *scale_dialog = nullptr;
536 SpinBox *scale = nullptr;
537
538 ConfirmationDialog *ease_dialog = nullptr;
539 OptionButton *transition_selection = nullptr;
540 OptionButton *ease_selection = nullptr;
541 SpinBox *ease_fps = nullptr;
542
543 void _select_all_tracks_for_copy();
544
545 void _edit_menu_about_to_popup();
546 void _edit_menu_pressed(int p_option);
547 int last_menu_track_opt = 0;
548
549 void _cleanup_animation(Ref<Animation> p_animation);
550
551 void _anim_duplicate_keys(bool transpose);
552
553 void _view_group_toggle();
554 Button *view_group = nullptr;
555 Button *selected_filter = nullptr;
556
557 void _selection_changed();
558
559 ConfirmationDialog *track_copy_dialog = nullptr;
560 Tree *track_copy_select = nullptr;
561
562 struct TrackClipboard {
563 NodePath full_path;
564 NodePath base_path;
565 Animation::TrackType track_type = Animation::TYPE_ANIMATION;
566 Animation::InterpolationType interp_type = Animation::INTERPOLATION_CUBIC_ANGLE;
567 Animation::UpdateMode update_mode = Animation::UPDATE_CAPTURE;
568 Animation::LoopMode loop_mode = Animation::LOOP_PINGPONG;
569 bool loop_wrap = false;
570 bool enabled = false;
571 bool use_blend = false;
572
573 struct Key {
574 float time = 0;
575 float transition = 0;
576 Variant value;
577 };
578 Vector<Key> keys;
579 };
580
581 Vector<TrackClipboard> track_clipboard;
582
583 void _insert_animation_key(NodePath p_path, const Variant &p_value);
584
585 void _pick_track_filter_text_changed(const String &p_newtext);
586 void _pick_track_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates);
587 void _pick_track_filter_input(const Ref<InputEvent> &p_ie);
588
589protected:
590 static void _bind_methods();
591 void _notification(int p_what);
592
593public:
594 // Public for use with callable_mp.
595 void _clear_selection(bool p_update = false);
596 void _key_selected(int p_key, bool p_single, int p_track);
597 void _key_deselected(int p_key, int p_track);
598
599 enum {
600 EDIT_COPY_TRACKS,
601 EDIT_COPY_TRACKS_CONFIRM,
602 EDIT_PASTE_TRACKS,
603 EDIT_SCALE_SELECTION,
604 EDIT_SCALE_FROM_CURSOR,
605 EDIT_SCALE_CONFIRM,
606 EDIT_EASE_SELECTION,
607 EDIT_EASE_CONFIRM,
608 EDIT_DUPLICATE_SELECTION,
609 EDIT_DUPLICATE_TRANSPOSED,
610 EDIT_ADD_RESET_KEY,
611 EDIT_DELETE_SELECTION,
612 EDIT_GOTO_NEXT_STEP,
613 EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY, // Next step without updating animation.
614 EDIT_GOTO_PREV_STEP,
615 EDIT_APPLY_RESET,
616 EDIT_BAKE_ANIMATION,
617 EDIT_BAKE_ANIMATION_CONFIRM,
618 EDIT_OPTIMIZE_ANIMATION,
619 EDIT_OPTIMIZE_ANIMATION_CONFIRM,
620 EDIT_CLEAN_UP_ANIMATION,
621 EDIT_CLEAN_UP_ANIMATION_CONFIRM
622 };
623
624 void add_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin);
625 void remove_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin);
626
627 void set_animation(const Ref<Animation> &p_anim, bool p_read_only);
628 Ref<Animation> get_current_animation() const;
629 void set_root(Node *p_root);
630 Node *get_root() const;
631 void update_keying();
632 bool has_keying() const;
633
634 Dictionary get_state() const;
635 void set_state(const Dictionary &p_state);
636
637 void cleanup();
638
639 void set_anim_pos(float p_pos);
640 void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false);
641 void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance);
642 void insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant p_value);
643 bool has_track(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type);
644 void make_insert_queue();
645 void commit_insert_queue();
646
647 void show_select_node_warning(bool p_show);
648
649 bool is_key_selected(int p_track, int p_key) const;
650 bool is_selection_active() const;
651 bool is_moving_selection() const;
652 bool is_snap_enabled() const;
653 float get_moving_selection_offset() const;
654 float snap_time(float p_value, bool p_relative = false);
655 bool is_grouping_tracks();
656
657 /** If `p_from_mouse_event` is `true`, handle Shift key presses for precise snapping. */
658 void goto_prev_step(bool p_from_mouse_event);
659
660 /** If `p_from_mouse_event` is `true`, handle Shift key presses for precise snapping. */
661 void goto_next_step(bool p_from_mouse_event, bool p_timeline_only = false);
662
663 MenuButton *get_edit_menu();
664 AnimationTrackEditor();
665 ~AnimationTrackEditor();
666};
667
668// AnimationTrackKeyEditEditorPlugin
669
670class AnimationTrackKeyEditEditor : public EditorProperty {
671 GDCLASS(AnimationTrackKeyEditEditor, EditorProperty);
672
673 Ref<Animation> animation;
674 int track = -1;
675 real_t key_ofs = 0.0;
676 bool use_fps = false;
677
678 EditorSpinSlider *spinner = nullptr;
679
680 struct KeyDataCache {
681 real_t time = 0.0;
682 float transition = 0.0;
683 Variant value;
684 } key_data_cache;
685
686 void _time_edit_entered();
687 void _time_edit_exited();
688
689public:
690 AnimationTrackKeyEditEditor(Ref<Animation> p_animation, int p_track, real_t p_key_ofs, bool p_use_fps);
691 ~AnimationTrackKeyEditEditor();
692};
693
694#endif // ANIMATION_TRACK_EDITOR_H
695