Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/animation/animation_blend_space_1d_editor.h
9902 views
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) 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_1d.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 AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin {
47
GDCLASS(AnimationNodeBlendSpace1DEditor, AnimationTreeNodeEditorPlugin);
48
49
Ref<AnimationNodeBlendSpace1D> blend_space;
50
bool read_only = false;
51
52
HBoxContainer *goto_parent_hb = nullptr;
53
Button *goto_parent = nullptr;
54
55
PanelContainer *panel = nullptr;
56
Button *tool_blend = nullptr;
57
Button *tool_select = nullptr;
58
Button *tool_create = nullptr;
59
VSeparator *tool_erase_sep = nullptr;
60
Button *tool_erase = nullptr;
61
Button *snap = nullptr;
62
SpinBox *snap_value = nullptr;
63
64
LineEdit *label_value = nullptr;
65
SpinBox *max_value = nullptr;
66
SpinBox *min_value = nullptr;
67
68
CheckBox *sync = nullptr;
69
OptionButton *interpolation = nullptr;
70
71
HBoxContainer *edit_hb = nullptr;
72
SpinBox *edit_value = nullptr;
73
Button *open_editor = nullptr;
74
75
int selected_point = -1;
76
77
Control *blend_space_draw = nullptr;
78
79
PanelContainer *error_panel = nullptr;
80
Label *error_label = nullptr;
81
82
bool updating = false;
83
84
static AnimationNodeBlendSpace1DEditor *singleton;
85
86
void _blend_space_gui_input(const Ref<InputEvent> &p_event);
87
void _blend_space_draw();
88
89
void _update_space();
90
91
void _config_changed(double);
92
void _labels_changed(String);
93
void _snap_toggled();
94
95
PopupMenu *menu = nullptr;
96
PopupMenu *animations_menu = nullptr;
97
Vector<String> animations_to_add;
98
float add_point_pos = 0.0f;
99
Vector<real_t> points;
100
101
bool dragging_selected_attempt = false;
102
bool dragging_selected = false;
103
Vector2 drag_from;
104
Vector2 drag_ofs;
105
106
void _add_menu_type(int p_index);
107
void _add_animation_type(int p_index);
108
109
void _tool_switch(int p_tool);
110
void _update_edited_point_pos();
111
void _update_tool_erase();
112
void _erase_selected();
113
void _edit_point_pos(double);
114
void _open_editor();
115
116
EditorFileDialog *open_file = nullptr;
117
Ref<AnimationNode> file_loaded;
118
void _file_opened(const String &p_file);
119
120
enum {
121
MENU_LOAD_FILE = 1000,
122
MENU_PASTE = 1001,
123
MENU_LOAD_FILE_CONFIRM = 1002
124
};
125
126
StringName get_blend_position_path() const;
127
128
protected:
129
void _notification(int p_what);
130
static void _bind_methods();
131
132
public:
133
static AnimationNodeBlendSpace1DEditor *get_singleton() { return singleton; }
134
virtual bool can_edit(const Ref<AnimationNode> &p_node) override;
135
virtual void edit(const Ref<AnimationNode> &p_node) override;
136
AnimationNodeBlendSpace1DEditor();
137
};
138
139