Path: blob/master/editor/animation/animation_blend_space_1d_editor.h
21733 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;5051PanelContainer *panel = nullptr;52Button *tool_blend = nullptr;53Button *tool_select = nullptr;54Button *tool_create = nullptr;55VSeparator *tool_erase_sep = nullptr;56Button *tool_erase = nullptr;57Button *snap = nullptr;58SpinBox *snap_value = nullptr;5960LineEdit *label_value = nullptr;61SpinBox *max_value = nullptr;62SpinBox *min_value = nullptr;6364CheckBox *sync = nullptr;65OptionButton *interpolation = nullptr;6667HBoxContainer *edit_hb = nullptr;68SpinBox *edit_value = nullptr;69Button *open_editor = nullptr;7071int selected_point = -1;7273Control *blend_space_draw = nullptr;7475PanelContainer *error_panel = nullptr;76Label *error_label = nullptr;7778bool updating = false;7980static AnimationNodeBlendSpace1DEditor *singleton;8182void _blend_space_gui_input(const Ref<InputEvent> &p_event);83void _blend_space_draw();8485void _update_space();8687void _config_changed(double);88void _labels_changed(String);89void _snap_toggled();9091PopupMenu *menu = nullptr;92PopupMenu *animations_menu = nullptr;93Vector<String> animations_to_add;94float add_point_pos = 0.0f;95Vector<real_t> points;9697bool dragging_blend_position = false;98bool dragging_selected_attempt = false;99bool dragging_selected = false;100Vector2 drag_from;101Vector2 drag_ofs;102103void _add_menu_type(int p_index);104void _add_animation_type(int p_index);105106void _tool_switch(int p_tool);107void _update_edited_point_pos();108void _update_tool_erase();109void _erase_selected();110void _edit_point_pos(double);111void _open_editor();112113EditorFileDialog *open_file = nullptr;114Ref<AnimationNode> file_loaded;115void _file_opened(const String &p_file);116117enum {118MENU_LOAD_FILE = 1000,119MENU_PASTE = 1001,120MENU_LOAD_FILE_CONFIRM = 1002121};122123StringName get_blend_position_path() const;124125protected:126void _notification(int p_what);127static void _bind_methods();128129public:130static AnimationNodeBlendSpace1DEditor *get_singleton() { return singleton; }131virtual bool can_edit(const Ref<AnimationNode> &p_node) override;132virtual void edit(const Ref<AnimationNode> &p_node) override;133AnimationNodeBlendSpace1DEditor();134};135136137