Debian Codegraph @

editor/animation/animation_blend_space_2d_editor.h

raw symbols SCIP
1 /**************************************************************************/
2 /* animation_blend_space_2d_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 #pragma once
32
33 #include "editor/animation/animation_tree_editor_plugin.h"
34 #include "editor/plugins/editor_plugin.h"
35 #include "scene/animation/animation_blend_space_2d.h"
36 #include "scene/gui/graph_edit.h"
37
38 class Button;
39 class CheckBox;
40 class LineEdit;
41 class OptionButton;
42 class PanelContainer;
43 class SpinBox;
44 class VSeparator;
45
46 class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin {
47 GDCLASS(AnimationNodeBlendSpace2DEditor, AnimationTreeNodeEditorPlugin);
48
49 Ref<AnimationNodeBlendSpace2D> blend_space;
50 bool read_only = false;
51
52 PanelContainer *panel = nullptr;
53 Button *tool_blend = nullptr;
54 Button *tool_select = nullptr;
55 Button *tool_create = nullptr;
56 Button *tool_triangle = nullptr;
57 VSeparator *tool_erase_sep = nullptr;
58 Button *tool_erase = nullptr;
59 Button *snap = nullptr;
60 SpinBox *snap_x = nullptr;
61 SpinBox *snap_y = nullptr;
62 CheckBox *sync = nullptr;
63 OptionButton *interpolation = nullptr;
64
65 Button *auto_triangles = nullptr;
66
67 LineEdit *label_x = nullptr;
68 LineEdit *label_y = nullptr;
69 SpinBox *max_x_value = nullptr;
70 SpinBox *min_x_value = nullptr;
71 SpinBox *max_y_value = nullptr;
72 SpinBox *min_y_value = nullptr;
73
74 HBoxContainer *edit_hb = nullptr;
75 SpinBox *edit_x = nullptr;
76 SpinBox *edit_y = nullptr;
77 Button *open_editor = nullptr;
78
79 int selected_point;
80 int selected_triangle;
81
82 Control *blend_space_draw = nullptr;
83
84 PanelContainer *error_panel = nullptr;
85 Label *error_label = nullptr;
86
87 bool updating;
88
89 static AnimationNodeBlendSpace2DEditor *singleton;
90
91 void _blend_space_gui_input(const Ref<InputEvent> &p_event);
92 void _blend_space_draw();
93
94 void _update_space();
95
96 void _config_changed(double);
97 void _labels_changed(String);
98 void _snap_toggled();
99
100 PopupMenu *menu = nullptr;
101 PopupMenu *animations_menu = nullptr;
102 Vector<String> animations_to_add;
103 Vector2 add_point_pos;
104 Vector<Vector2> points;
105
106 bool dragging_blend_position;
107 bool dragging_selected_attempt;
108 bool dragging_selected;
109 Vector2 drag_from;
110 Vector2 drag_ofs;
111
112 Vector<int> making_triangle;
113
114 void _add_menu_type(int p_index);
115 void _add_animation_type(int p_index);
116
117 void _tool_switch(int p_tool);
118 void _update_edited_point_pos();
119 void _update_tool_erase();
120 void _erase_selected();
121 void _edit_point_pos(double);
122 void _open_editor();
123
124 void _auto_triangles_toggled();
125
126 StringName get_blend_position_path() const;
127
128 EditorFileDialog *open_file = nullptr;
129 Ref<AnimationNode> file_loaded;
130 void _file_opened(const String &p_file);
131
132 enum {
133 MENU_LOAD_FILE = 1000,
134 MENU_PASTE = 1001,
135 MENU_LOAD_FILE_CONFIRM = 1002
136 };
137
138 void _blend_space_changed();
139
140 protected:
141 void _notification(int p_what);
142 static void _bind_methods();
143
144 public:
145 static AnimationNodeBlendSpace2DEditor *get_singleton() { return singleton; }
146 virtual bool can_edit(const Ref<AnimationNode> &p_node) override;
147 virtual void edit(const Ref<AnimationNode> &p_node) override;
148 AnimationNodeBlendSpace2DEditor();
149 };