2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* animation_editor.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-07 22:11:42 +00:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00: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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#ifndef ANIMATION_EDITOR_H
|
|
|
|
#define ANIMATION_EDITOR_H
|
|
|
|
|
|
|
|
#include "scene/gui/control.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/file_dialog.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/gui/menu_button.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/scroll_bar.h"
|
|
|
|
#include "scene/gui/slider.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/gui/spin_box.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/tab_container.h"
|
2017-01-14 09:52:54 +00:00
|
|
|
#include "scene/gui/texture_rect.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/gui/tool_button.h"
|
2015-01-03 20:24:16 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "editor_data.h"
|
|
|
|
#include "property_editor.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/animation/animation_cache.h"
|
|
|
|
#include "scene/resources/animation.h"
|
|
|
|
#include "scene_tree_editor.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class AnimationKeyEdit;
|
2015-05-25 04:46:45 +00:00
|
|
|
class AnimationCurveEdit;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
class AnimationKeyEditor : public VBoxContainer {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(AnimationKeyEditor, VBoxContainer);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
/*
|
2014-02-10 01:10:30 +00:00
|
|
|
enum {
|
|
|
|
|
|
|
|
MENU_NEW_ANIMATION,
|
|
|
|
MENU_OPEN_ANIMATION,
|
|
|
|
MENU_EDIT_ANIMATION,
|
|
|
|
MENU_CLOSE_ANIMATION,
|
|
|
|
MENU_KEYING_ACTIVE,
|
|
|
|
MENU_SET_ROOT_NODE,
|
|
|
|
MENU_SYNC_TO_PLAYER,
|
|
|
|
MENU_ANIM_BASE=100,
|
|
|
|
};
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
2015-11-18 21:55:05 +00:00
|
|
|
ADD_TRACK_MENU_ADD_VALUE_TRACK,
|
|
|
|
ADD_TRACK_MENU_ADD_TRANSFORM_TRACK,
|
|
|
|
ADD_TRACK_MENU_ADD_CALL_TRACK,
|
2014-02-10 01:10:30 +00:00
|
|
|
TRACK_MENU_SCALE,
|
|
|
|
TRACK_MENU_SCALE_PIVOT,
|
|
|
|
TRACK_MENU_MOVE_UP,
|
|
|
|
TRACK_MENU_MOVE_DOWN,
|
|
|
|
TRACK_MENU_REMOVE,
|
|
|
|
TRACK_MENU_DUPLICATE,
|
|
|
|
TRACK_MENU_DUPLICATE_TRANSPOSE,
|
|
|
|
TRACK_MENU_SET_ALL_TRANS_LINEAR,
|
|
|
|
TRACK_MENU_SET_ALL_TRANS_CONSTANT,
|
|
|
|
TRACK_MENU_SET_ALL_TRANS_OUT,
|
|
|
|
TRACK_MENU_SET_ALL_TRANS_IN,
|
|
|
|
TRACK_MENU_SET_ALL_TRANS_INOUT,
|
|
|
|
TRACK_MENU_SET_ALL_TRANS_OUTIN,
|
|
|
|
TRACK_MENU_NEXT_STEP,
|
|
|
|
TRACK_MENU_PREV_STEP,
|
2015-05-25 04:46:45 +00:00
|
|
|
TRACK_MENU_OPTIMIZE,
|
2015-12-05 17:18:22 +00:00
|
|
|
TRACK_MENU_CLEAN_UP,
|
|
|
|
TRACK_MENU_CLEAN_UP_CONFIRM,
|
2015-05-25 04:46:45 +00:00
|
|
|
CURVE_SET_LINEAR,
|
|
|
|
CURVE_SET_IN,
|
|
|
|
CURVE_SET_OUT,
|
|
|
|
CURVE_SET_INOUT,
|
|
|
|
CURVE_SET_OUTIN,
|
|
|
|
CURVE_SET_CONSTANT
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2016-06-19 01:22:03 +00:00
|
|
|
enum {
|
|
|
|
RIGHT_MENU_DUPLICATE,
|
|
|
|
RIGHT_MENU_DUPLICATE_TRANSPOSE,
|
|
|
|
RIGHT_MENU_REMOVE
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
struct MouseOver {
|
|
|
|
|
|
|
|
enum Over {
|
|
|
|
OVER_NONE,
|
|
|
|
OVER_NAME,
|
|
|
|
OVER_KEY,
|
|
|
|
OVER_VALUE,
|
|
|
|
OVER_INTERP,
|
2017-01-09 03:41:16 +00:00
|
|
|
OVER_WRAP,
|
2014-02-10 01:10:30 +00:00
|
|
|
OVER_UP,
|
|
|
|
OVER_DOWN,
|
|
|
|
OVER_REMOVE,
|
|
|
|
OVER_ADD_KEY,
|
|
|
|
};
|
|
|
|
|
|
|
|
Over over;
|
|
|
|
int track;
|
|
|
|
int over_key;
|
|
|
|
|
|
|
|
} mouse_over;
|
|
|
|
|
|
|
|
struct SelectedKey {
|
|
|
|
|
|
|
|
int track;
|
|
|
|
int key;
|
2017-03-05 15:44:50 +00:00
|
|
|
bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; };
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct KeyInfo {
|
|
|
|
|
|
|
|
float pos;
|
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<SelectedKey, KeyInfo> selection;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
struct ClickOver {
|
|
|
|
|
|
|
|
enum Click {
|
|
|
|
|
|
|
|
CLICK_NONE,
|
|
|
|
CLICK_RESIZE_NAMES,
|
|
|
|
CLICK_DRAG_TIMELINE,
|
|
|
|
CLICK_MOVE_KEYS,
|
|
|
|
CLICK_SELECT_KEYS
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
SelectedKey selk;
|
|
|
|
bool shift;
|
|
|
|
Click click;
|
|
|
|
Point2 at;
|
|
|
|
Point2 to;
|
|
|
|
} click;
|
|
|
|
|
|
|
|
float timeline_pos;
|
|
|
|
|
|
|
|
float name_column_ratio;
|
|
|
|
|
|
|
|
int track_name_editing;
|
|
|
|
int interp_editing;
|
|
|
|
int cont_editing;
|
2017-01-09 03:41:16 +00:00
|
|
|
int wrap_editing;
|
2014-02-10 01:10:30 +00:00
|
|
|
int selected_track;
|
2017-01-09 03:41:16 +00:00
|
|
|
int track_ofs[5];
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
int last_menu_track_opt;
|
|
|
|
LineEdit *track_name;
|
|
|
|
PopupMenu *track_menu;
|
|
|
|
PopupMenu *type_menu;
|
|
|
|
|
2015-01-03 20:24:16 +00:00
|
|
|
Control *ec;
|
2017-01-12 21:27:27 +00:00
|
|
|
TextureRect *zoomicon;
|
2014-02-10 01:10:30 +00:00
|
|
|
HSlider *zoom;
|
|
|
|
//MenuButton *menu;
|
|
|
|
SpinBox *length;
|
|
|
|
Button *loop;
|
|
|
|
bool keying;
|
|
|
|
ToolButton *edit_button;
|
|
|
|
ToolButton *move_up_button;
|
|
|
|
ToolButton *move_down_button;
|
|
|
|
ToolButton *remove_button;
|
|
|
|
|
2015-05-25 04:46:45 +00:00
|
|
|
ToolButton *curve_linear;
|
|
|
|
ToolButton *curve_in;
|
|
|
|
ToolButton *curve_out;
|
|
|
|
ToolButton *curve_inout;
|
|
|
|
ToolButton *curve_outin;
|
|
|
|
ToolButton *curve_constant;
|
|
|
|
|
2014-11-12 14:23:23 +00:00
|
|
|
ConfirmationDialog *optimize_dialog;
|
|
|
|
SpinBox *optimize_linear_error;
|
|
|
|
SpinBox *optimize_angular_error;
|
|
|
|
SpinBox *optimize_max_angle;
|
|
|
|
|
2015-12-05 17:18:22 +00:00
|
|
|
ConfirmationDialog *cleanup_dialog;
|
|
|
|
CheckButton *cleanup_keys;
|
|
|
|
CheckButton *cleanup_tracks;
|
|
|
|
CheckButton *cleanup_all;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
SpinBox *step;
|
|
|
|
|
2015-11-18 21:55:05 +00:00
|
|
|
MenuButton *menu_add_track;
|
2014-02-10 01:10:30 +00:00
|
|
|
MenuButton *menu_track;
|
|
|
|
|
|
|
|
HScrollBar *h_scroll;
|
|
|
|
VScrollBar *v_scroll;
|
|
|
|
|
|
|
|
Control *track_editor;
|
|
|
|
Control *track_pos;
|
2015-05-25 04:46:45 +00:00
|
|
|
TabContainer *key_editor_tab;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
ConfirmationDialog *scale_dialog;
|
|
|
|
SpinBox *scale;
|
|
|
|
|
2016-03-08 23:00:52 +00:00
|
|
|
PropertyEditor *key_editor;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-08-30 13:10:51 +00:00
|
|
|
SceneTreeDialog *call_select;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Animation> animation;
|
|
|
|
void _update_paths();
|
|
|
|
|
|
|
|
int last_idx;
|
|
|
|
|
|
|
|
Node *root;
|
|
|
|
|
|
|
|
UndoRedo *undo_redo;
|
2017-03-05 15:44:50 +00:00
|
|
|
EditorHistory *history;
|
2014-02-10 01:10:30 +00:00
|
|
|
ConfirmationDialog *insert_confirm;
|
|
|
|
|
|
|
|
AnimationKeyEdit *key_edit;
|
2015-05-25 04:46:45 +00:00
|
|
|
AnimationCurveEdit *curve_edit;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
bool inserting;
|
|
|
|
|
|
|
|
bool updating;
|
|
|
|
bool te_drawing;
|
|
|
|
|
|
|
|
void _animation_len_changed(float p_len);
|
|
|
|
void _animation_loop_changed();
|
|
|
|
void _step_changed(float p_len);
|
|
|
|
|
|
|
|
struct InsertData {
|
|
|
|
|
|
|
|
Animation::TrackType type;
|
|
|
|
NodePath path;
|
|
|
|
int track_idx;
|
|
|
|
Variant value;
|
|
|
|
String query;
|
2015-05-25 04:46:45 +00:00
|
|
|
bool advance;
|
2017-03-05 15:44:50 +00:00
|
|
|
}; /* insert_data;*/
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
bool insert_query;
|
|
|
|
List<InsertData> insert_data;
|
|
|
|
uint64_t insert_frame;
|
|
|
|
|
|
|
|
int cvi_track;
|
|
|
|
float cvi_pos;
|
|
|
|
|
|
|
|
int right_data_size_cache;
|
|
|
|
|
|
|
|
EditorSelection *editor_selection;
|
|
|
|
|
2016-07-22 12:42:12 +00:00
|
|
|
Label *select_anim_warning;
|
2016-01-17 23:03:57 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
float _get_zoom_scale() const;
|
|
|
|
|
|
|
|
void _track_editor_draw();
|
2017-05-20 15:38:03 +00:00
|
|
|
void _track_editor_gui_input(const Ref<InputEvent> &p_input);
|
2017-09-10 13:37:49 +00:00
|
|
|
void _track_position_draw();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _track_name_changed(const String &p_name);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _track_menu_selected(int p_idx);
|
|
|
|
void _confirm_insert_list();
|
2017-08-12 16:52:50 +00:00
|
|
|
int _confirm_insert(InsertData p_id, int p_last_track = -1);
|
2017-03-05 15:44:50 +00:00
|
|
|
void _query_insert(const InsertData &p_id);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _update_menu();
|
|
|
|
bool insert_queue;
|
|
|
|
void _insert_delay();
|
|
|
|
void _scale();
|
|
|
|
|
2015-05-25 04:46:45 +00:00
|
|
|
void _clear_selection();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//void _browse_path();
|
|
|
|
|
|
|
|
StringName alc;
|
|
|
|
|
|
|
|
void _animation_changed();
|
2014-11-12 14:23:23 +00:00
|
|
|
void _animation_optimize();
|
2015-12-05 17:18:22 +00:00
|
|
|
void _cleanup_animation(Ref<Animation> p_animation);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _scroll_changed(double);
|
|
|
|
|
2015-11-18 21:55:05 +00:00
|
|
|
void _menu_add_track(int p_type);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _menu_track(int p_type);
|
|
|
|
|
2017-03-05 15:44:50 +00: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);
|
2015-05-25 04:46:45 +00:00
|
|
|
void _curve_transition_changed(float p_what);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-01-31 23:06:37 +00:00
|
|
|
PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _create_value_item(int p_type);
|
2017-03-05 15:44:50 +00:00
|
|
|
void _pane_drag(const Point2 &p_delta);
|
2015-05-25 04:46:45 +00:00
|
|
|
bool _edit_if_single_selection();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-05-25 04:46:45 +00:00
|
|
|
void _toggle_edit_curves();
|
2014-02-10 01:10:30 +00:00
|
|
|
void _animation_len_update();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _add_call_track(const NodePath &p_base);
|
2015-08-30 13:10:51 +00:00
|
|
|
|
2016-06-19 01:22:03 +00:00
|
|
|
void _anim_duplicate_keys(bool transpose = false);
|
|
|
|
void _anim_delete_keys();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _root_removed();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
protected:
|
2014-02-10 01:10:30 +00:00
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
|
|
|
void set_animation(const Ref<Animation> &p_anim);
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Animation> get_current_animation() const;
|
|
|
|
void set_root(Node *p_root);
|
|
|
|
Node *get_root() const;
|
2016-01-27 14:10:51 +00:00
|
|
|
void update_keying();
|
2014-02-10 01:10:30 +00:00
|
|
|
bool has_keying() const;
|
|
|
|
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void set_anim_pos(float p_pos);
|
2017-03-05 15:44:50 +00:00
|
|
|
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);
|
|
|
|
void insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
void show_select_node_warning(bool p_show) { select_anim_warning->set_visible(p_show); }
|
2016-01-17 23:03:57 +00:00
|
|
|
AnimationKeyEditor();
|
2014-02-10 01:10:30 +00:00
|
|
|
~AnimationKeyEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ANIMATION_EDITOR_H
|