/*************************************************************************/ /* editor_data.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #ifndef EDITOR_DATA_H #define EDITOR_DATA_H #include "core/object/undo_redo.h" #include "core/templates/list.h" #include "scene/resources/texture.h" class ConfigFile; class EditorPlugin; /** * Stores the history of objects which have been selected for editing in the Editor & the Inspector. * * Used in the editor to set & access the currently edited object, as well as the history of objects which have been edited. */ class EditorSelectionHistory { // Stores the object & property (if relevant). struct _Object { Ref ref; ObjectID object; String property; bool inspector_only = false; }; // Represents the selection of an object for editing. struct HistoryElement { // The sub-resources of the parent object (first in the path) that have been edited. // For example, Node2D -> nested resource -> nested resource, if edited each individually in their own inspector. Vector<_Object> path; // The current point in the path. This is always equal to the last item in the path - it is never decremented. int level = 0; }; friend class EditorData; Vector history; int current_elem_idx; // The current history element being edited. public: void cleanup_history(); bool is_at_beginning() const; bool is_at_end() const; // Adds an object to the selection history. A property name can be passed if the target is a subresource of the given object. // If the object should not change the main screen plugin, it can be set as inspector only. void add_object(ObjectID p_object, const String &p_property = String(), bool p_inspector_only = false); int get_history_len(); int get_history_pos(); // Gets an object from the history. The most recent object would be the object with p_obj = get_history_len() - 1. ObjectID get_history_obj(int p_obj) const; bool is_history_obj_inspector_only(int p_obj) const; bool next(); bool previous(); ObjectID get_current(); bool is_current_inspector_only() const; // Gets the size of the path of the current history item. int get_path_size() const; // Gets the object of the current history item, if valid. ObjectID get_path_object(int p_index) const; // Gets the property of the current history item. String get_path_property(int p_index) const; void clear(); EditorSelectionHistory(); }; class EditorSelection; class EditorData { public: struct CustomType { String name; Ref