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
21733 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
PanelContainer *panel = nullptr;
53
Button *tool_blend = nullptr;
54
Button *tool_select = nullptr;
55
Button *tool_create = nullptr;
56
VSeparator *tool_erase_sep = nullptr;
57
Button *tool_erase = nullptr;
58
Button *snap = nullptr;
59
SpinBox *snap_value = nullptr;
60
61
LineEdit *label_value = nullptr;
62
SpinBox *max_value = nullptr;
63
SpinBox *min_value = nullptr;
64
65
CheckBox *sync = nullptr;
66
OptionButton *interpolation = nullptr;
67
68
HBoxContainer *edit_hb = nullptr;
69
SpinBox *edit_value = nullptr;
70
Button *open_editor = nullptr;
71
72
int selected_point = -1;
73
74
Control *blend_space_draw = nullptr;
75
76
PanelContainer *error_panel = nullptr;
77
Label *error_label = nullptr;
78
79
bool updating = false;
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 = nullptr;
93
PopupMenu *animations_menu = nullptr;
94
Vector<String> animations_to_add;
95
float add_point_pos = 0.0f;
96
Vector<real_t> points;
97
98
bool dragging_blend_position = false;
99
bool dragging_selected_attempt = false;
100
bool dragging_selected = false;
101
Vector2 drag_from;
102
Vector2 drag_ofs;
103
104
void _add_menu_type(int p_index);
105
void _add_animation_type(int p_index);
106
107
void _tool_switch(int p_tool);
108
void _update_edited_point_pos();
109
void _update_tool_erase();
110
void _erase_selected();
111
void _edit_point_pos(double);
112
void _open_editor();
113
114
EditorFileDialog *open_file = nullptr;
115
Ref<AnimationNode> file_loaded;
116
void _file_opened(const String &p_file);
117
118
enum {
119
MENU_LOAD_FILE = 1000,
120
MENU_PASTE = 1001,
121
MENU_LOAD_FILE_CONFIRM = 1002
122
};
123
124
StringName get_blend_position_path() const;
125
126
protected:
127
void _notification(int p_what);
128
static void _bind_methods();
129
130
public:
131
static AnimationNodeBlendSpace1DEditor *get_singleton() { return singleton; }
132
virtual bool can_edit(const Ref<AnimationNode> &p_node) override;
133
virtual void edit(const Ref<AnimationNode> &p_node) override;
134
AnimationNodeBlendSpace1DEditor();
135
};
136
137