Debian Codegraph @

editor/animation/animation_tree_editor_plugin.h

raw symbols SCIP
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/docks/editor_dock.h"
34 #include "editor/plugins/editor_plugin.h"
35 #include "scene/animation/animation_tree.h"
36 #include "scene/gui/graph_edit.h"
37
38 class Button;
39 class EditorFileDialog;
40 class ScrollContainer;
41
42 class AnimationTreeNodeEditorPlugin : public VBoxContainer {
43 GDCLASS(AnimationTreeNodeEditorPlugin, VBoxContainer);
44
45 public:
46 virtual bool can_edit(const Ref<AnimationNode> &p_node) = 0;
47 virtual void edit(const Ref<AnimationNode> &p_node) = 0;
48 };
49
50 class AnimationTreeEditor : public EditorDock {
51 GDCLASS(AnimationTreeEditor, EditorDock);
52
53 ScrollContainer *path_edit = nullptr;
54 HBoxContainer *path_hb = nullptr;
55
56 AnimationTree *tree = nullptr;
57 MarginContainer *editor_base = nullptr;
58
59 Vector<String> button_path;
60 Vector<String> edited_path;
61 Vector<AnimationTreeNodeEditorPlugin *> editors;
62
63 void _update_path();
64 void _clear_editors();
65 ObjectID current_root;
66
67 void _path_button_pressed(int p_path);
68 void _animation_list_changed();
69
70 static Vector<String> get_animation_list();
71
72 protected:
73 void _notification(int p_what);
74 void _node_removed(Node *p_node);
75
76 static AnimationTreeEditor *singleton;
77
78 public:
79 AnimationTree *get_animation_tree() { return tree; }
80 void add_plugin(AnimationTreeNodeEditorPlugin *p_editor);
81 void remove_plugin(AnimationTreeNodeEditorPlugin *p_editor);
82
83 String get_base_path();
84
85 bool can_edit(const Ref<AnimationNode> &p_node) const;
86
87 void edit_path(const Vector<String> &p_path);
88 Vector<String> get_edited_path() const;
89
90 void enter_editor(const String &p_path = "");
91 static AnimationTreeEditor *get_singleton() { return singleton; }
92 void edit(AnimationTree *p_tree);
93 AnimationTreeEditor();
94 };
95
96 class AnimationTreeEditorPlugin : public EditorPlugin {
97 GDCLASS(AnimationTreeEditorPlugin, EditorPlugin);
98
99 AnimationTreeEditor *anim_tree_editor = 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 };