| 
									
										
										
										
											2018-08-29 22:38:13 +02:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  animation_track_editor.h                                             */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							|  |  |  | /*                      https://godotengine.org                          */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2021-01-01 20:13:46 +01:00
										 |  |  | /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).   */ | 
					
						
							| 
									
										
										
										
											2018-08-29 22:38:13 +02:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the       */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including   */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,   */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to    */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to */ | 
					
						
							|  |  |  | /* the following conditions:                                             */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be        */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.       */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | #ifndef ANIMATION_TRACK_EDITOR_H
 | 
					
						
							|  |  |  | #define ANIMATION_TRACK_EDITOR_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-23 19:52:49 +02:00
										 |  |  | #include "editor/editor_data.h"
 | 
					
						
							|  |  |  | #include "editor/editor_spin_slider.h"
 | 
					
						
							|  |  |  | #include "editor/property_editor.h"
 | 
					
						
							|  |  |  | #include "editor/property_selector.h"
 | 
					
						
							|  |  |  | #include "scene/animation/animation_cache.h"
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | #include "scene/gui/control.h"
 | 
					
						
							|  |  |  | #include "scene/gui/file_dialog.h"
 | 
					
						
							|  |  |  | #include "scene/gui/menu_button.h"
 | 
					
						
							|  |  |  | #include "scene/gui/scroll_bar.h"
 | 
					
						
							|  |  |  | #include "scene/gui/slider.h"
 | 
					
						
							|  |  |  | #include "scene/gui/spin_box.h"
 | 
					
						
							|  |  |  | #include "scene/gui/tab_container.h"
 | 
					
						
							|  |  |  | #include "scene/gui/texture_rect.h"
 | 
					
						
							|  |  |  | #include "scene/resources/animation.h"
 | 
					
						
							|  |  |  | #include "scene_tree_editor.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-20 11:46:44 +01:00
										 |  |  | class AnimationPlayer; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | class AnimationTimelineEdit : public Range { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(AnimationTimelineEdit, Range); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Ref<Animation> animation; | 
					
						
							|  |  |  | 	int name_limit; | 
					
						
							|  |  |  | 	Range *zoom; | 
					
						
							|  |  |  | 	Range *h_scroll; | 
					
						
							|  |  |  | 	float play_position_pos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	HBoxContainer *len_hb; | 
					
						
							|  |  |  | 	EditorSpinSlider *length; | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 	Button *loop; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	TextureRect *time_icon; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	MenuButton *add_track; | 
					
						
							|  |  |  | 	Control *play_position; //separate control used to draw so updates for only position changed are much faster
 | 
					
						
							|  |  |  | 	HScrollBar *hscroll; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _zoom_changed(double); | 
					
						
							|  |  |  | 	void _anim_length_changed(double p_new_len); | 
					
						
							|  |  |  | 	void _anim_loop_pressed(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _play_position_draw(); | 
					
						
							|  |  |  | 	UndoRedo *undo_redo; | 
					
						
							|  |  |  | 	Rect2 hsize_rect; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool editing; | 
					
						
							| 
									
										
										
										
											2019-04-14 16:43:38 -03:00
										 |  |  | 	bool use_fps; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	bool panning_timeline; | 
					
						
							|  |  |  | 	float panning_timeline_from; | 
					
						
							|  |  |  | 	float panning_timeline_at; | 
					
						
							|  |  |  | 	bool dragging_timeline; | 
					
						
							|  |  |  | 	bool dragging_hsize; | 
					
						
							|  |  |  | 	float dragging_hsize_from; | 
					
						
							|  |  |  | 	float dragging_hsize_at; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _gui_input(const Ref<InputEvent> &p_event); | 
					
						
							|  |  |  | 	void _track_added(int p_track); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	int get_name_limit() const; | 
					
						
							|  |  |  | 	int get_buttons_width() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	float get_zoom_scale() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual Size2 get_minimum_size() const override; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void set_animation(const Ref<Animation> &p_animation); | 
					
						
							|  |  |  | 	void set_zoom(Range *p_zoom); | 
					
						
							|  |  |  | 	Range *get_zoom() const { return zoom; } | 
					
						
							|  |  |  | 	void set_undo_redo(UndoRedo *p_undo_redo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_play_position(float p_pos); | 
					
						
							|  |  |  | 	float get_play_position() const; | 
					
						
							|  |  |  | 	void update_play_position(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void update_values(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-14 16:43:38 -03:00
										 |  |  | 	void set_use_fps(bool p_use_fps); | 
					
						
							|  |  |  | 	bool is_using_fps() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void set_hscroll(HScrollBar *p_hscroll); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	AnimationTimelineEdit(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AnimationTrackEditor; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AnimationTrackEdit : public Control { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(AnimationTrackEdit, Control); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	enum { | 
					
						
							|  |  |  | 		MENU_CALL_MODE_CONTINUOUS, | 
					
						
							|  |  |  | 		MENU_CALL_MODE_DISCRETE, | 
					
						
							|  |  |  | 		MENU_CALL_MODE_TRIGGER, | 
					
						
							|  |  |  | 		MENU_CALL_MODE_CAPTURE, | 
					
						
							|  |  |  | 		MENU_INTERPOLATION_NEAREST, | 
					
						
							|  |  |  | 		MENU_INTERPOLATION_LINEAR, | 
					
						
							|  |  |  | 		MENU_INTERPOLATION_CUBIC, | 
					
						
							|  |  |  | 		MENU_LOOP_WRAP, | 
					
						
							|  |  |  | 		MENU_LOOP_CLAMP, | 
					
						
							|  |  |  | 		MENU_KEY_INSERT, | 
					
						
							|  |  |  | 		MENU_KEY_DUPLICATE, | 
					
						
							|  |  |  | 		MENU_KEY_DELETE | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	AnimationTimelineEdit *timeline; | 
					
						
							|  |  |  | 	UndoRedo *undo_redo; | 
					
						
							| 
									
										
										
										
											2020-03-19 23:32:09 -03:00
										 |  |  | 	Popup *path_popup; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	LineEdit *path; | 
					
						
							|  |  |  | 	Node *root; | 
					
						
							|  |  |  | 	Control *play_position; //separate control used to draw so updates for only position changed are much faster
 | 
					
						
							|  |  |  | 	float play_position_pos; | 
					
						
							| 
									
										
										
										
											2019-03-06 10:22:38 -03:00
										 |  |  | 	NodePath node_path; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Ref<Animation> animation; | 
					
						
							|  |  |  | 	int track; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Rect2 check_rect; | 
					
						
							|  |  |  | 	Rect2 path_rect; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Rect2 update_mode_rect; | 
					
						
							|  |  |  | 	Rect2 interp_mode_rect; | 
					
						
							|  |  |  | 	Rect2 loop_mode_rect; | 
					
						
							|  |  |  | 	Rect2 remove_rect; | 
					
						
							|  |  |  | 	Rect2 bezier_edit_rect; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-11 15:43:37 -03:00
										 |  |  | 	Ref<Texture2D> type_icon; | 
					
						
							|  |  |  | 	Ref<Texture2D> selected_icon; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	PopupMenu *menu; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool clicking_on_name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _zoom_changed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-11 15:43:37 -03:00
										 |  |  | 	Ref<Texture2D> icon_cache; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	String path_cache; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _menu_selected(int p_index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _path_entered(const String &p_text); | 
					
						
							|  |  |  | 	void _play_position_draw(); | 
					
						
							| 
									
										
										
										
											2019-06-23 19:52:49 +02:00
										 |  |  | 	bool _is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-23 19:52:49 +02:00
										 |  |  | 	mutable int dropping_at; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	float insert_at_pos; | 
					
						
							|  |  |  | 	bool moving_selection_attempt; | 
					
						
							|  |  |  | 	int select_single_attempt; | 
					
						
							|  |  |  | 	bool moving_selection; | 
					
						
							|  |  |  | 	float moving_selection_from_ofs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool in_group; | 
					
						
							|  |  |  | 	AnimationTrackEditor *editor; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual void _gui_input(const Ref<InputEvent> &p_event); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual Variant get_drag_data(const Point2 &p_point) override; | 
					
						
							|  |  |  | 	virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override; | 
					
						
							|  |  |  | 	virtual void drop_data(const Point2 &p_point, const Variant &p_data) override; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual String get_tooltip(const Point2 &p_pos) const override; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	virtual int get_key_height() const; | 
					
						
							|  |  |  | 	virtual Rect2 get_key_rect(int p_index, float p_pixels_sec); | 
					
						
							|  |  |  | 	virtual bool is_key_selectable_by_distance() const; | 
					
						
							|  |  |  | 	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); | 
					
						
							|  |  |  | 	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); | 
					
						
							|  |  |  | 	virtual void draw_bg(int p_clip_left, int p_clip_right); | 
					
						
							|  |  |  | 	virtual void draw_fg(int p_clip_left, int p_clip_right); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//helper
 | 
					
						
							| 
									
										
										
										
											2019-06-11 15:43:37 -03:00
										 |  |  | 	void draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void draw_rect_clipped(const Rect2 &p_rect, const Color &p_color, bool p_filled = true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int get_track() const; | 
					
						
							|  |  |  | 	Ref<Animation> get_animation() const; | 
					
						
							|  |  |  | 	AnimationTimelineEdit *get_timeline() const { return timeline; } | 
					
						
							|  |  |  | 	AnimationTrackEditor *get_editor() const { return editor; } | 
					
						
							|  |  |  | 	UndoRedo *get_undo_redo() const { return undo_redo; } | 
					
						
							| 
									
										
										
										
											2019-03-06 10:22:38 -03:00
										 |  |  | 	NodePath get_path() const; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void set_animation_and_track(const Ref<Animation> &p_animation, int p_track); | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual Size2 get_minimum_size() const override; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void set_undo_redo(UndoRedo *p_undo_redo); | 
					
						
							|  |  |  | 	void set_timeline(AnimationTimelineEdit *p_timeline); | 
					
						
							|  |  |  | 	void set_editor(AnimationTrackEditor *p_editor); | 
					
						
							|  |  |  | 	void set_root(Node *p_root); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_play_position(float p_pos); | 
					
						
							|  |  |  | 	void update_play_position(); | 
					
						
							|  |  |  | 	void cancel_drop(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_in_group(bool p_enable); | 
					
						
							| 
									
										
										
										
											2019-06-19 13:34:22 +03:00
										 |  |  | 	void append_to_selection(const Rect2 &p_box, bool p_deselection); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	AnimationTrackEdit(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AnimationTrackEditPlugin : public Reference { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(AnimationTrackEditPlugin, Reference); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | public: | 
					
						
							|  |  |  | 	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); | 
					
						
							|  |  |  | 	virtual AnimationTrackEdit *create_audio_track_edit(); | 
					
						
							|  |  |  | 	virtual AnimationTrackEdit *create_animation_track_edit(Object *p_object); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AnimationTrackKeyEdit; | 
					
						
							| 
									
										
										
										
											2019-07-22 03:43:40 -03:00
										 |  |  | class AnimationMultiTrackKeyEdit; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | class AnimationBezierTrackEdit; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AnimationTrackEditGroup : public Control { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(AnimationTrackEditGroup, Control); | 
					
						
							| 
									
										
										
										
											2019-06-11 15:43:37 -03:00
										 |  |  | 	Ref<Texture2D> icon; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	String node_name; | 
					
						
							|  |  |  | 	NodePath node; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 	Node *root = nullptr; | 
					
						
							|  |  |  | 	AnimationTimelineEdit *timeline = nullptr; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _zoom_changed(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-06-11 15:43:37 -03:00
										 |  |  | 	void set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node); | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual Size2 get_minimum_size() const override; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void set_timeline(AnimationTimelineEdit *p_timeline); | 
					
						
							|  |  |  | 	void set_root(Node *p_root); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	AnimationTrackEditGroup(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AnimationTrackEditor : public VBoxContainer { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(AnimationTrackEditor, VBoxContainer); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	enum { | 
					
						
							|  |  |  | 		EDIT_COPY_TRACKS, | 
					
						
							|  |  |  | 		EDIT_COPY_TRACKS_CONFIRM, | 
					
						
							|  |  |  | 		EDIT_PASTE_TRACKS, | 
					
						
							|  |  |  | 		EDIT_SCALE_SELECTION, | 
					
						
							|  |  |  | 		EDIT_SCALE_FROM_CURSOR, | 
					
						
							|  |  |  | 		EDIT_SCALE_CONFIRM, | 
					
						
							|  |  |  | 		EDIT_DUPLICATE_SELECTION, | 
					
						
							|  |  |  | 		EDIT_DUPLICATE_TRANSPOSED, | 
					
						
							|  |  |  | 		EDIT_DELETE_SELECTION, | 
					
						
							|  |  |  | 		EDIT_GOTO_NEXT_STEP, | 
					
						
							|  |  |  | 		EDIT_GOTO_PREV_STEP, | 
					
						
							| 
									
										
										
										
											2020-12-20 11:46:44 +01:00
										 |  |  | 		EDIT_APPLY_RESET, | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 		EDIT_OPTIMIZE_ANIMATION, | 
					
						
							|  |  |  | 		EDIT_OPTIMIZE_ANIMATION_CONFIRM, | 
					
						
							|  |  |  | 		EDIT_CLEAN_UP_ANIMATION, | 
					
						
							|  |  |  | 		EDIT_CLEAN_UP_ANIMATION_CONFIRM | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<Animation> animation; | 
					
						
							|  |  |  | 	Node *root; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	MenuButton *edit; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-08 21:03:27 -03:00
										 |  |  | 	PanelContainer *main_panel; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	HScrollBar *hscroll; | 
					
						
							|  |  |  | 	ScrollContainer *scroll; | 
					
						
							|  |  |  | 	VBoxContainer *track_vbox; | 
					
						
							|  |  |  | 	AnimationBezierTrackEdit *bezier_edit; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-04 02:20:57 -03:00
										 |  |  | 	Label *info_message; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	AnimationTimelineEdit *timeline; | 
					
						
							|  |  |  | 	HSlider *zoom; | 
					
						
							|  |  |  | 	EditorSpinSlider *step; | 
					
						
							|  |  |  | 	TextureRect *zoom_icon; | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 	Button *snap; | 
					
						
							| 
									
										
										
										
											2019-04-14 16:43:38 -03:00
										 |  |  | 	OptionButton *snap_mode; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 15:02:34 +10:00
										 |  |  | 	Button *imported_anim_warning; | 
					
						
							| 
									
										
										
										
											2020-02-21 17:44:59 +01:00
										 |  |  | 	void _show_imported_anim_warning(); | 
					
						
							| 
									
										
										
										
											2019-04-23 15:02:34 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-14 16:43:38 -03:00
										 |  |  | 	void _snap_mode_changed(int p_mode); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	Vector<AnimationTrackEdit *> track_edits; | 
					
						
							|  |  |  | 	Vector<AnimationTrackEditGroup *> groups; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-06 10:22:38 -03:00
										 |  |  | 	bool animation_changing_awaiting_update; | 
					
						
							|  |  |  | 	void _animation_update(); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	int _get_track_selected(); | 
					
						
							|  |  |  | 	void _animation_changed(); | 
					
						
							|  |  |  | 	void _update_tracks(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _name_limit_changed(); | 
					
						
							|  |  |  | 	void _timeline_changed(float p_new_pos, bool p_drag); | 
					
						
							|  |  |  | 	void _track_remove_request(int p_track); | 
					
						
							| 
									
										
										
										
											2019-05-25 13:01:44 -03:00
										 |  |  | 	void _track_grab_focus(int p_track); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	UndoRedo *undo_redo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _update_scroll(double); | 
					
						
							|  |  |  | 	void _update_step(double p_new_step); | 
					
						
							| 
									
										
										
										
											2019-06-26 15:08:25 +02:00
										 |  |  | 	void _update_length(double p_new_len); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void _dropped_track(int p_from_track, int p_to_track); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _add_track(int p_type); | 
					
						
							|  |  |  | 	void _new_track_node_selected(NodePath p_path); | 
					
						
							|  |  |  | 	void _new_track_property_selected(String p_name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-14 16:43:38 -03:00
										 |  |  | 	void _update_step_spinbox(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	PropertySelector *prop_selector; | 
					
						
							|  |  |  | 	PropertySelector *method_selector; | 
					
						
							|  |  |  | 	SceneTreeDialog *pick_track; | 
					
						
							|  |  |  | 	int adding_track_type; | 
					
						
							|  |  |  | 	NodePath adding_track_path; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool keying; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct InsertData { | 
					
						
							|  |  |  | 		Animation::TrackType type; | 
					
						
							|  |  |  | 		NodePath path; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		int track_idx = 0; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 		Variant value; | 
					
						
							|  |  |  | 		String query; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		bool advance = false; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	}; /* insert_data;*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Label *insert_confirm_text; | 
					
						
							|  |  |  | 	CheckBox *insert_confirm_bezier; | 
					
						
							| 
									
										
										
										
											2020-12-20 11:46:44 +01:00
										 |  |  | 	CheckBox *insert_confirm_reset; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	ConfirmationDialog *insert_confirm; | 
					
						
							|  |  |  | 	bool insert_queue; | 
					
						
							|  |  |  | 	bool inserting; | 
					
						
							|  |  |  | 	bool insert_query; | 
					
						
							|  |  |  | 	List<InsertData> insert_data; | 
					
						
							|  |  |  | 	uint64_t insert_frame; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _query_insert(const InsertData &p_id); | 
					
						
							| 
									
										
										
										
											2020-12-20 11:46:44 +01:00
										 |  |  | 	Ref<Animation> _create_and_get_reset_animation(); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void _confirm_insert_list(); | 
					
						
							| 
									
										
										
										
											2020-12-20 11:46:44 +01:00
										 |  |  | 	struct TrackIndices { | 
					
						
							|  |  |  | 		int normal; | 
					
						
							|  |  |  | 		int reset; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		TrackIndices(const Animation *p_anim = nullptr, const Animation *p_reset_anim = nullptr) { | 
					
						
							|  |  |  | 			normal = p_anim ? p_anim->get_track_count() : 0; | 
					
						
							|  |  |  | 			reset = p_reset_anim ? p_reset_anim->get_track_count() : 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2021-01-01 22:24:26 +01:00
										 |  |  | 	TrackIndices _confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, Ref<Animation> p_reset_anim, bool p_create_beziers); | 
					
						
							| 
									
										
										
										
											2020-12-20 11:46:44 +01:00
										 |  |  | 	void _insert_delay(bool p_create_reset, bool p_create_beziers); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _root_removed(Node *p_root); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val = nullptr); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _timeline_value_changed(double); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	float insert_key_from_track_call_ofs; | 
					
						
							|  |  |  | 	int insert_key_from_track_call_track; | 
					
						
							|  |  |  | 	void _insert_key_from_track(float p_ofs, int p_track); | 
					
						
							|  |  |  | 	void _add_method_key(const String &p_method); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 22:16:53 -03:00
										 |  |  | 	void _clear_selection(bool p_update = false); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void _clear_selection_for_anim(const Ref<Animation> &p_anim); | 
					
						
							|  |  |  | 	void _select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//selection
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct SelectedKey { | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		int track = 0; | 
					
						
							|  |  |  | 		int key = 0; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 		bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; }; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct KeyInfo { | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		float pos = 0; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Map<SelectedKey, KeyInfo> selection; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _key_selected(int p_key, bool p_single, int p_track); | 
					
						
							|  |  |  | 	void _key_deselected(int p_key, int p_track); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool moving_selection; | 
					
						
							|  |  |  | 	float moving_selection_offset; | 
					
						
							|  |  |  | 	void _move_selection_begin(); | 
					
						
							|  |  |  | 	void _move_selection(float p_offset); | 
					
						
							|  |  |  | 	void _move_selection_commit(); | 
					
						
							|  |  |  | 	void _move_selection_cancel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	AnimationTrackKeyEdit *key_edit; | 
					
						
							| 
									
										
										
										
											2019-07-22 03:43:40 -03:00
										 |  |  | 	AnimationMultiTrackKeyEdit *multi_key_edit; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void _update_key_edit(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _clear_key_edit(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Control *box_selection; | 
					
						
							|  |  |  | 	void _box_selection_draw(); | 
					
						
							|  |  |  | 	bool box_selecting; | 
					
						
							|  |  |  | 	Vector2 box_selecting_from; | 
					
						
							|  |  |  | 	Rect2 box_select_rect; | 
					
						
							|  |  |  | 	void _scroll_input(const Ref<InputEvent> &p_event); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 07:33:00 +01:00
										 |  |  | 	Vector<Ref<AnimationTrackEditPlugin>> track_edit_plugins; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _cancel_bezier_edit(); | 
					
						
							|  |  |  | 	void _bezier_edit(int p_for_track); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	////////////// edit menu stuff
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ConfirmationDialog *optimize_dialog; | 
					
						
							|  |  |  | 	SpinBox *optimize_linear_error; | 
					
						
							|  |  |  | 	SpinBox *optimize_angular_error; | 
					
						
							|  |  |  | 	SpinBox *optimize_max_angle; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ConfirmationDialog *cleanup_dialog; | 
					
						
							| 
									
										
										
										
											2019-07-04 17:30:44 +02:00
										 |  |  | 	CheckBox *cleanup_keys; | 
					
						
							|  |  |  | 	CheckBox *cleanup_tracks; | 
					
						
							|  |  |  | 	CheckBox *cleanup_all; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ConfirmationDialog *scale_dialog; | 
					
						
							|  |  |  | 	SpinBox *scale; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-19 14:00:15 +03:00
										 |  |  | 	void _select_all_tracks_for_copy(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-20 11:46:44 +01:00
										 |  |  | 	void _edit_menu_about_to_popup(); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void _edit_menu_pressed(int p_option); | 
					
						
							|  |  |  | 	int last_menu_track_opt; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _cleanup_animation(Ref<Animation> p_animation); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _anim_duplicate_keys(bool transpose); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _view_group_toggle(); | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 	Button *view_group; | 
					
						
							|  |  |  | 	Button *selected_filter; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _selection_changed(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ConfirmationDialog *track_copy_dialog; | 
					
						
							|  |  |  | 	Tree *track_copy_select; | 
					
						
							| 
									
										
										
										
											2019-06-19 14:00:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	struct TrackClipboard { | 
					
						
							|  |  |  | 		NodePath full_path; | 
					
						
							|  |  |  | 		NodePath base_path; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		Animation::TrackType track_type = Animation::TrackType::TYPE_ANIMATION; | 
					
						
							|  |  |  | 		Animation::InterpolationType interp_type = Animation::InterpolationType::INTERPOLATION_CUBIC; | 
					
						
							|  |  |  | 		Animation::UpdateMode update_mode = Animation::UpdateMode::UPDATE_CAPTURE; | 
					
						
							|  |  |  | 		bool loop_wrap = false; | 
					
						
							|  |  |  | 		bool enabled = false; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		struct Key { | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 			float time = 0; | 
					
						
							|  |  |  | 			float transition = 0; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 			Variant value; | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 		Vector<Key> keys; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Vector<TrackClipboard> track_clipboard; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _insert_animation_key(NodePath p_path, const Variant &p_value); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-12 16:40:17 +01:00
										 |  |  | 	void _pick_track_filter_text_changed(const String &p_newtext); | 
					
						
							|  |  |  | 	void _pick_track_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates); | 
					
						
							|  |  |  | 	void _pick_track_filter_input(const Ref<InputEvent> &p_ie); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	void add_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin); | 
					
						
							|  |  |  | 	void remove_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_animation(const Ref<Animation> &p_anim); | 
					
						
							|  |  |  | 	Ref<Animation> get_current_animation() const; | 
					
						
							|  |  |  | 	void set_root(Node *p_root); | 
					
						
							|  |  |  | 	Node *get_root() const; | 
					
						
							|  |  |  | 	void update_keying(); | 
					
						
							|  |  |  | 	bool has_keying() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-14 16:43:38 -03:00
										 |  |  | 	Dictionary get_state() const; | 
					
						
							|  |  |  | 	void set_state(const Dictionary &p_state); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	void cleanup(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_anim_pos(float p_pos); | 
					
						
							|  |  |  | 	void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false); | 
					
						
							|  |  |  | 	void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance); | 
					
						
							| 
									
										
										
										
											2020-03-26 18:49:16 -03:00
										 |  |  | 	void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void show_select_node_warning(bool p_show); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool is_key_selected(int p_track, int p_key) const; | 
					
						
							|  |  |  | 	bool is_selection_active() const; | 
					
						
							|  |  |  | 	bool is_moving_selection() const; | 
					
						
							| 
									
										
										
										
											2019-08-06 01:15:20 +02:00
										 |  |  | 	bool is_snap_enabled() const; | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 	float get_moving_selection_offset() const; | 
					
						
							| 
									
										
										
										
											2019-11-17 23:34:36 +01:00
										 |  |  | 	float snap_time(float p_value, bool p_relative = false); | 
					
						
							| 
									
										
										
										
											2019-05-25 13:01:44 -03:00
										 |  |  | 	bool is_grouping_tracks(); | 
					
						
							| 
									
										
										
										
											2018-06-07 12:46:14 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	MenuButton *get_edit_menu(); | 
					
						
							|  |  |  | 	AnimationTrackEditor(); | 
					
						
							|  |  |  | 	~AnimationTrackEditor(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // ANIMATION_TRACK_EDITOR_H
 |