Path: blob/master/editor/animation/animation_blend_space_1d_editor.h
9902 views
/**************************************************************************/1/* animation_blend_space_1d_editor.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/animation/animation_tree_editor_plugin.h"33#include "editor/plugins/editor_plugin.h"34#include "scene/animation/animation_blend_space_1d.h"35#include "scene/gui/graph_edit.h"3637class Button;38class CheckBox;39class LineEdit;40class OptionButton;41class PanelContainer;42class SpinBox;43class VSeparator;4445class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin {46GDCLASS(AnimationNodeBlendSpace1DEditor, AnimationTreeNodeEditorPlugin);4748Ref<AnimationNodeBlendSpace1D> blend_space;49bool read_only = false;5051HBoxContainer *goto_parent_hb = nullptr;52Button *goto_parent = nullptr;5354PanelContainer *panel = nullptr;55Button *tool_blend = nullptr;56Button *tool_select = nullptr;57Button *tool_create = nullptr;58VSeparator *tool_erase_sep = nullptr;59Button *tool_erase = nullptr;60Button *snap = nullptr;61SpinBox *snap_value = nullptr;6263LineEdit *label_value = nullptr;64SpinBox *max_value = nullptr;65SpinBox *min_value = nullptr;6667CheckBox *sync = nullptr;68OptionButton *interpolation = nullptr;6970HBoxContainer *edit_hb = nullptr;71SpinBox *edit_value = nullptr;72Button *open_editor = nullptr;7374int selected_point = -1;7576Control *blend_space_draw = nullptr;7778PanelContainer *error_panel = nullptr;79Label *error_label = nullptr;8081bool updating = false;8283static AnimationNodeBlendSpace1DEditor *singleton;8485void _blend_space_gui_input(const Ref<InputEvent> &p_event);86void _blend_space_draw();8788void _update_space();8990void _config_changed(double);91void _labels_changed(String);92void _snap_toggled();9394PopupMenu *menu = nullptr;95PopupMenu *animations_menu = nullptr;96Vector<String> animations_to_add;97float add_point_pos = 0.0f;98Vector<real_t> points;99100bool dragging_selected_attempt = false;101bool dragging_selected = false;102Vector2 drag_from;103Vector2 drag_ofs;104105void _add_menu_type(int p_index);106void _add_animation_type(int p_index);107108void _tool_switch(int p_tool);109void _update_edited_point_pos();110void _update_tool_erase();111void _erase_selected();112void _edit_point_pos(double);113void _open_editor();114115EditorFileDialog *open_file = nullptr;116Ref<AnimationNode> file_loaded;117void _file_opened(const String &p_file);118119enum {120MENU_LOAD_FILE = 1000,121MENU_PASTE = 1001,122MENU_LOAD_FILE_CONFIRM = 1002123};124125StringName get_blend_position_path() const;126127protected:128void _notification(int p_what);129static void _bind_methods();130131public:132static AnimationNodeBlendSpace1DEditor *get_singleton() { return singleton; }133virtual bool can_edit(const Ref<AnimationNode> &p_node) override;134virtual void edit(const Ref<AnimationNode> &p_node) override;135AnimationNodeBlendSpace1DEditor();136};137138139