Path: blob/master/editor/animation/animation_blend_space_2d_editor.h
9896 views
/**************************************************************************/1/* animation_blend_space_2d_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_2d.h"35#include "scene/gui/graph_edit.h"3637class Button;38class CheckBox;39class LineEdit;40class OptionButton;41class PanelContainer;42class SpinBox;43class VSeparator;4445class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin {46GDCLASS(AnimationNodeBlendSpace2DEditor, AnimationTreeNodeEditorPlugin);4748Ref<AnimationNodeBlendSpace2D> blend_space;49bool read_only = false;5051PanelContainer *panel = nullptr;52Button *tool_blend = nullptr;53Button *tool_select = nullptr;54Button *tool_create = nullptr;55Button *tool_triangle = nullptr;56VSeparator *tool_erase_sep = nullptr;57Button *tool_erase = nullptr;58Button *snap = nullptr;59SpinBox *snap_x = nullptr;60SpinBox *snap_y = nullptr;61CheckBox *sync = nullptr;62OptionButton *interpolation = nullptr;6364Button *auto_triangles = nullptr;6566LineEdit *label_x = nullptr;67LineEdit *label_y = nullptr;68SpinBox *max_x_value = nullptr;69SpinBox *min_x_value = nullptr;70SpinBox *max_y_value = nullptr;71SpinBox *min_y_value = nullptr;7273HBoxContainer *edit_hb = nullptr;74SpinBox *edit_x = nullptr;75SpinBox *edit_y = nullptr;76Button *open_editor = nullptr;7778int selected_point;79int selected_triangle;8081Control *blend_space_draw = nullptr;8283PanelContainer *error_panel = nullptr;84Label *error_label = nullptr;8586bool updating;8788static AnimationNodeBlendSpace2DEditor *singleton;8990void _blend_space_gui_input(const Ref<InputEvent> &p_event);91void _blend_space_draw();9293void _update_space();9495void _config_changed(double);96void _labels_changed(String);97void _snap_toggled();9899PopupMenu *menu = nullptr;100PopupMenu *animations_menu = nullptr;101Vector<String> animations_to_add;102Vector2 add_point_pos;103Vector<Vector2> points;104105bool dragging_selected_attempt;106bool dragging_selected;107Vector2 drag_from;108Vector2 drag_ofs;109110Vector<int> making_triangle;111112void _add_menu_type(int p_index);113void _add_animation_type(int p_index);114115void _tool_switch(int p_tool);116void _update_edited_point_pos();117void _update_tool_erase();118void _erase_selected();119void _edit_point_pos(double);120void _open_editor();121122void _auto_triangles_toggled();123124StringName get_blend_position_path() const;125126EditorFileDialog *open_file = nullptr;127Ref<AnimationNode> file_loaded;128void _file_opened(const String &p_file);129130enum {131MENU_LOAD_FILE = 1000,132MENU_PASTE = 1001,133MENU_LOAD_FILE_CONFIRM = 1002134};135136void _blend_space_changed();137138protected:139void _notification(int p_what);140static void _bind_methods();141142public:143static AnimationNodeBlendSpace2DEditor *get_singleton() { return singleton; }144virtual bool can_edit(const Ref<AnimationNode> &p_node) override;145virtual void edit(const Ref<AnimationNode> &p_node) override;146AnimationNodeBlendSpace2DEditor();147};148149150