1 /*************************************************************************/ 2 /* animation_blend_space_1d_editor.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ 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_BLEND_SPACE_1D_EDITOR_H 32 #define ANIMATION_BLEND_SPACE_1D_EDITOR_H 33 34 #include "editor/editor_node.h" 35 #include "editor/editor_plugin.h" 36 #include "editor/plugins/animation_tree_editor_plugin.h" 37 #include "editor/property_editor.h" 38 #include "scene/animation/animation_blend_space_1d.h" 39 #include "scene/gui/button.h" 40 #include "scene/gui/graph_edit.h" 41 #include "scene/gui/popup.h" 42 #include "scene/gui/tree.h" 43 44 class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { 45 46 GDCLASS(AnimationNodeBlendSpace1DEditor, AnimationTreeNodeEditorPlugin); 47 48 Ref<AnimationNodeBlendSpace1D> blend_space; 49 50 HBoxContainer *goto_parent_hb; 51 ToolButton *goto_parent; 52 53 PanelContainer *panel; 54 ToolButton *tool_blend; 55 ToolButton *tool_select; 56 ToolButton *tool_create; 57 VSeparator *tool_erase_sep; 58 ToolButton *tool_erase; 59 ToolButton *snap; 60 SpinBox *snap_value; 61 62 LineEdit *label_value; 63 SpinBox *max_value; 64 SpinBox *min_value; 65 66 HBoxContainer *edit_hb; 67 SpinBox *edit_value; 68 Button *open_editor; 69 70 int selected_point; 71 72 Control *blend_space_draw; 73 74 PanelContainer *error_panel; 75 Label *error_label; 76 77 bool updating; 78 79 UndoRedo *undo_redo; 80 81 static AnimationNodeBlendSpace1DEditor *singleton; 82 83 void _blend_space_gui_input(const Ref<InputEvent> &p_event); 84 void _blend_space_draw(); 85 86 void _update_space(); 87 88 void _config_changed(double); 89 void _labels_changed(String); 90 void _snap_toggled(); 91 92 PopupMenu *menu; 93 PopupMenu *animations_menu; 94 Vector<String> animations_to_add; 95 float add_point_pos; 96 Vector<float> points; 97 98 bool dragging_selected_attempt; 99 bool dragging_selected; 100 Vector2 drag_from; 101 Vector2 drag_ofs; 102 103 void _add_menu_type(int p_index); 104 void _add_animation_type(int p_index); 105 106 void _tool_switch(int p_tool); 107 void _update_edited_point_pos(); 108 void _update_tool_erase(); 109 void _erase_selected(); 110 void _edit_point_pos(double); 111 void _open_editor(); 112 113 void _goto_parent(); 114 115 EditorFileDialog *open_file; 116 Ref<AnimationNode> file_loaded; 117 void _file_opened(const String &p_file); 118 119 enum { 120 MENU_LOAD_FILE = 1000, 121 MENU_PASTE = 1001, 122 MENU_LOAD_FILE_CONFIRM = 1002 123 }; 124 125 StringName get_blend_position_path() const; 126 127 protected: 128 void _notification(int p_what); 129 static void _bind_methods(); 130 131 public: get_singleton()132 static AnimationNodeBlendSpace1DEditor *get_singleton() { return singleton; } 133 virtual bool can_edit(const Ref<AnimationNode> &p_node); 134 virtual void edit(const Ref<AnimationNode> &p_node); 135 AnimationNodeBlendSpace1DEditor(); 136 }; 137 138 #endif // ANIMATION_BLEND_SPACE_1D_EDITOR_H 139