Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/animation/animation_tree_editor_plugin.h
9896 views
1
/**************************************************************************/
2
/* animation_tree_editor_plugin.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/plugins/editor_plugin.h"
34
#include "scene/animation/animation_tree.h"
35
#include "scene/gui/graph_edit.h"
36
37
class Button;
38
class EditorFileDialog;
39
class ScrollContainer;
40
41
class AnimationTreeNodeEditorPlugin : public VBoxContainer {
42
GDCLASS(AnimationTreeNodeEditorPlugin, VBoxContainer);
43
44
public:
45
virtual bool can_edit(const Ref<AnimationNode> &p_node) = 0;
46
virtual void edit(const Ref<AnimationNode> &p_node) = 0;
47
};
48
49
class AnimationTreeEditor : public VBoxContainer {
50
GDCLASS(AnimationTreeEditor, VBoxContainer);
51
52
ScrollContainer *path_edit = nullptr;
53
HBoxContainer *path_hb = nullptr;
54
55
AnimationTree *tree = nullptr;
56
MarginContainer *editor_base = nullptr;
57
58
Vector<String> button_path;
59
Vector<String> edited_path;
60
Vector<AnimationTreeNodeEditorPlugin *> editors;
61
62
void _update_path();
63
void _clear_editors();
64
ObjectID current_root;
65
66
void _path_button_pressed(int p_path);
67
void _animation_list_changed();
68
69
static Vector<String> get_animation_list();
70
71
protected:
72
void _notification(int p_what);
73
void _node_removed(Node *p_node);
74
75
static AnimationTreeEditor *singleton;
76
77
public:
78
AnimationTree *get_animation_tree() { return tree; }
79
void add_plugin(AnimationTreeNodeEditorPlugin *p_editor);
80
void remove_plugin(AnimationTreeNodeEditorPlugin *p_editor);
81
82
String get_base_path();
83
84
bool can_edit(const Ref<AnimationNode> &p_node) const;
85
86
void edit_path(const Vector<String> &p_path);
87
Vector<String> get_edited_path() const;
88
89
void enter_editor(const String &p_path = "");
90
static AnimationTreeEditor *get_singleton() { return singleton; }
91
void edit(AnimationTree *p_tree);
92
AnimationTreeEditor();
93
};
94
95
class AnimationTreeEditorPlugin : public EditorPlugin {
96
GDCLASS(AnimationTreeEditorPlugin, EditorPlugin);
97
98
AnimationTreeEditor *anim_tree_editor = nullptr;
99
Button *button = nullptr;
100
101
public:
102
virtual String get_plugin_name() const override { return "AnimationTree"; }
103
bool has_main_screen() const override { return false; }
104
virtual void edit(Object *p_object) override;
105
virtual bool handles(Object *p_object) const override;
106
virtual void make_visible(bool p_visible) override;
107
108
AnimationTreeEditorPlugin();
109
};
110
111