Path: blob/master/editor/animation/animation_tree_editor_plugin.h
9896 views
/**************************************************************************/1/* animation_tree_editor_plugin.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/plugins/editor_plugin.h"33#include "scene/animation/animation_tree.h"34#include "scene/gui/graph_edit.h"3536class Button;37class EditorFileDialog;38class ScrollContainer;3940class AnimationTreeNodeEditorPlugin : public VBoxContainer {41GDCLASS(AnimationTreeNodeEditorPlugin, VBoxContainer);4243public:44virtual bool can_edit(const Ref<AnimationNode> &p_node) = 0;45virtual void edit(const Ref<AnimationNode> &p_node) = 0;46};4748class AnimationTreeEditor : public VBoxContainer {49GDCLASS(AnimationTreeEditor, VBoxContainer);5051ScrollContainer *path_edit = nullptr;52HBoxContainer *path_hb = nullptr;5354AnimationTree *tree = nullptr;55MarginContainer *editor_base = nullptr;5657Vector<String> button_path;58Vector<String> edited_path;59Vector<AnimationTreeNodeEditorPlugin *> editors;6061void _update_path();62void _clear_editors();63ObjectID current_root;6465void _path_button_pressed(int p_path);66void _animation_list_changed();6768static Vector<String> get_animation_list();6970protected:71void _notification(int p_what);72void _node_removed(Node *p_node);7374static AnimationTreeEditor *singleton;7576public:77AnimationTree *get_animation_tree() { return tree; }78void add_plugin(AnimationTreeNodeEditorPlugin *p_editor);79void remove_plugin(AnimationTreeNodeEditorPlugin *p_editor);8081String get_base_path();8283bool can_edit(const Ref<AnimationNode> &p_node) const;8485void edit_path(const Vector<String> &p_path);86Vector<String> get_edited_path() const;8788void enter_editor(const String &p_path = "");89static AnimationTreeEditor *get_singleton() { return singleton; }90void edit(AnimationTree *p_tree);91AnimationTreeEditor();92};9394class AnimationTreeEditorPlugin : public EditorPlugin {95GDCLASS(AnimationTreeEditorPlugin, EditorPlugin);9697AnimationTreeEditor *anim_tree_editor = nullptr;98Button *button = nullptr;99100public:101virtual String get_plugin_name() const override { return "AnimationTree"; }102bool has_main_screen() const override { return false; }103virtual void edit(Object *p_object) override;104virtual bool handles(Object *p_object) const override;105virtual void make_visible(bool p_visible) override;106107AnimationTreeEditorPlugin();108};109110111