2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* editor_inspector.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
2018-05-16 19:19:33 +02:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
#ifndef EDITOR_INSPECTOR_H
|
|
|
|
#define EDITOR_INSPECTOR_H
|
|
|
|
|
2022-03-23 02:46:59 +01:00
|
|
|
#include "editor_property_name_processor.h"
|
2018-05-17 23:02:16 +02:00
|
|
|
#include "scene/gui/box_container.h"
|
2018-05-15 22:12:35 +02:00
|
|
|
#include "scene/gui/scroll_container.h"
|
2022-11-19 12:45:49 +01:00
|
|
|
|
|
|
|
class AcceptDialog;
|
|
|
|
class Button;
|
|
|
|
class ConfirmationDialog;
|
|
|
|
class LineEdit;
|
|
|
|
class OptionButton;
|
|
|
|
class PanelContainer;
|
|
|
|
class PopupMenu;
|
|
|
|
class SpinBox;
|
|
|
|
class TextureRect;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2018-11-25 14:46:26 +01:00
|
|
|
class EditorPropertyRevert {
|
|
|
|
public:
|
2021-08-02 13:58:02 +02:00
|
|
|
static bool get_instantiated_node_original_property(Node *p_node, const StringName &p_prop, Variant &value, bool p_check_class_default = true);
|
2018-11-25 14:46:26 +01:00
|
|
|
static bool is_node_property_different(Node *p_node, const Variant &p_current, const Variant &p_orig);
|
2021-02-21 03:03:07 +01:00
|
|
|
static bool is_property_value_different(const Variant &p_a, const Variant &p_b);
|
2021-12-11 14:03:48 +01:00
|
|
|
static Variant get_property_revert_value(Object *p_object, const StringName &p_property, bool *r_is_valid);
|
2018-11-25 14:46:26 +01:00
|
|
|
|
2022-06-19 00:42:02 +02:00
|
|
|
static bool can_property_revert(Object *p_object, const StringName &p_property, const Variant *p_custom_current_value = nullptr);
|
2018-11-25 14:46:26 +01:00
|
|
|
};
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
class EditorProperty : public Container {
|
2019-03-19 19:35:57 +01:00
|
|
|
GDCLASS(EditorProperty, Container);
|
|
|
|
|
2020-06-08 15:25:52 +02:00
|
|
|
public:
|
|
|
|
enum MenuItems {
|
2022-09-30 16:44:27 +02:00
|
|
|
MENU_COPY_VALUE,
|
|
|
|
MENU_PASTE_VALUE,
|
2020-06-08 15:25:52 +02:00
|
|
|
MENU_COPY_PROPERTY_PATH,
|
2021-10-26 21:12:25 +02:00
|
|
|
MENU_PIN_VALUE,
|
2022-03-28 22:37:01 +02:00
|
|
|
MENU_OPEN_DOCUMENTATION,
|
2020-06-08 15:25:52 +02:00
|
|
|
};
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
private:
|
|
|
|
String label;
|
|
|
|
int text_size;
|
|
|
|
friend class EditorInspector;
|
2022-04-04 15:06:57 +02:00
|
|
|
Object *object = nullptr;
|
2018-05-15 22:12:35 +02:00
|
|
|
StringName property;
|
2022-03-13 14:23:44 +01:00
|
|
|
String property_path;
|
2022-03-28 22:37:01 +02:00
|
|
|
String doc_path;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
int property_usage;
|
|
|
|
|
2022-02-15 15:56:58 +01:00
|
|
|
bool read_only = false;
|
|
|
|
bool checkable = false;
|
|
|
|
bool checked = false;
|
|
|
|
bool draw_warning = false;
|
|
|
|
bool keying = false;
|
|
|
|
bool deletable = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2018-07-19 00:37:17 +02:00
|
|
|
Rect2 right_child_rect;
|
|
|
|
Rect2 bottom_child_rect;
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
Rect2 keying_rect;
|
2020-09-03 13:22:16 +02:00
|
|
|
bool keying_hover = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
Rect2 revert_rect;
|
2020-09-03 13:22:16 +02:00
|
|
|
bool revert_hover = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
Rect2 check_rect;
|
2020-09-03 13:22:16 +02:00
|
|
|
bool check_hover = false;
|
2020-04-17 04:52:00 +02:00
|
|
|
Rect2 delete_rect;
|
2020-09-03 13:22:16 +02:00
|
|
|
bool delete_hover = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-02-15 15:56:58 +01:00
|
|
|
bool can_revert = false;
|
|
|
|
bool can_pin = false;
|
|
|
|
bool pin_hidden = false;
|
|
|
|
bool pinned = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-02-15 15:56:58 +01:00
|
|
|
bool use_folding = false;
|
|
|
|
bool draw_top_bg = true;
|
2018-05-17 23:02:16 +02:00
|
|
|
|
2021-10-26 21:12:25 +02:00
|
|
|
void _update_popup();
|
2018-05-15 22:12:35 +02:00
|
|
|
void _focusable_focused(int p_index);
|
|
|
|
|
2022-02-15 15:56:58 +01:00
|
|
|
bool selectable = true;
|
|
|
|
bool selected = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
int selected_focusable;
|
|
|
|
|
2018-07-14 23:15:42 +02:00
|
|
|
float split_ratio;
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
Vector<Control *> focusables;
|
2022-04-04 15:06:57 +02:00
|
|
|
Control *label_reference = nullptr;
|
|
|
|
Control *bottom_editor = nullptr;
|
|
|
|
PopupMenu *menu = nullptr;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, Variant> cache;
|
2021-02-10 21:18:45 +01:00
|
|
|
|
2021-08-22 03:52:44 +02:00
|
|
|
GDVIRTUAL0(_update_property)
|
2022-09-19 01:21:55 +02:00
|
|
|
GDVIRTUAL1(_set_read_only, bool)
|
|
|
|
|
2021-10-26 21:12:25 +02:00
|
|
|
void _update_pin_flags();
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2021-08-16 04:42:24 +02:00
|
|
|
virtual void _set_read_only(bool p_read_only);
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2021-08-22 17:37:22 +02:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
2022-01-11 14:59:52 +01:00
|
|
|
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
|
2021-03-19 06:42:56 +01:00
|
|
|
const Color *_get_property_colors();
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-06-19 00:42:02 +02:00
|
|
|
virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const;
|
|
|
|
virtual StringName _get_revert_property() const;
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
public:
|
2019-01-18 17:01:24 +01:00
|
|
|
void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false);
|
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void set_label(const String &p_label);
|
|
|
|
String get_label() const;
|
|
|
|
|
|
|
|
void set_read_only(bool p_read_only);
|
|
|
|
bool is_read_only() const;
|
|
|
|
|
|
|
|
Object *get_edited_object();
|
2022-06-19 00:42:02 +02:00
|
|
|
StringName get_edited_property() const;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-03-28 22:37:01 +02:00
|
|
|
void set_doc_path(const String &p_doc_path);
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
virtual void update_property();
|
2022-05-01 03:24:45 +02:00
|
|
|
void update_editor_property_status();
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
virtual bool use_keying_next() const;
|
|
|
|
|
|
|
|
void set_checkable(bool p_checkable);
|
|
|
|
bool is_checkable() const;
|
|
|
|
|
|
|
|
void set_checked(bool p_checked);
|
|
|
|
bool is_checked() const;
|
|
|
|
|
2021-09-30 17:08:04 +02:00
|
|
|
void set_draw_warning(bool p_draw_warning);
|
|
|
|
bool is_draw_warning() const;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void set_keying(bool p_keying);
|
|
|
|
bool is_keying() const;
|
|
|
|
|
2020-04-17 04:52:00 +02:00
|
|
|
void set_deletable(bool p_enable);
|
|
|
|
bool is_deletable() const;
|
2018-05-15 22:12:35 +02:00
|
|
|
void add_focusable(Control *p_control);
|
|
|
|
void select(int p_focusable = -1);
|
|
|
|
void deselect();
|
|
|
|
bool is_selected() const;
|
|
|
|
|
|
|
|
void set_label_reference(Control *p_control);
|
2019-06-26 15:08:25 +02:00
|
|
|
void set_bottom_editor(Control *p_control);
|
2018-05-17 23:02:16 +02:00
|
|
|
|
|
|
|
void set_use_folding(bool p_use_folding);
|
|
|
|
bool is_using_folding() const;
|
|
|
|
|
|
|
|
virtual void expand_all_folding();
|
|
|
|
virtual void collapse_all_folding();
|
2022-07-30 15:12:51 +02:00
|
|
|
virtual void expand_revertable();
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Variant get_drag_data(const Point2 &p_point) override;
|
2021-02-10 21:18:45 +01:00
|
|
|
virtual void update_cache();
|
|
|
|
virtual bool is_cache_valid() const;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2018-05-19 21:09:38 +02:00
|
|
|
void set_selectable(bool p_selectable);
|
|
|
|
bool is_selectable() const;
|
|
|
|
|
2018-07-14 23:15:42 +02:00
|
|
|
void set_name_split_ratio(float p_ratio);
|
|
|
|
float get_name_split_ratio() const;
|
|
|
|
|
2018-05-19 21:09:38 +02:00
|
|
|
void set_object_and_property(Object *p_object, const StringName &p_property);
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Control *make_custom_tooltip(const String &p_text) const override;
|
2018-07-20 23:14:33 +02:00
|
|
|
|
2018-08-07 17:19:19 +02:00
|
|
|
void set_draw_top_bg(bool p_draw) { draw_top_bg = p_draw; }
|
|
|
|
|
2018-10-29 21:38:51 +01:00
|
|
|
bool can_revert_to_default() const { return can_revert; }
|
|
|
|
|
2020-06-08 15:25:52 +02:00
|
|
|
void menu_option(int p_option);
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
EditorProperty();
|
|
|
|
};
|
|
|
|
|
2021-06-04 18:03:15 +02:00
|
|
|
class EditorInspectorPlugin : public RefCounted {
|
|
|
|
GDCLASS(EditorInspectorPlugin, RefCounted);
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-05-24 00:35:01 +02:00
|
|
|
public:
|
2018-05-15 22:12:35 +02:00
|
|
|
friend class EditorInspector;
|
|
|
|
struct AddedEditor {
|
2020-11-24 10:12:55 +01:00
|
|
|
Control *property_editor = nullptr;
|
2018-05-15 22:12:35 +02:00
|
|
|
Vector<String> properties;
|
|
|
|
String label;
|
2022-05-24 00:35:01 +02:00
|
|
|
bool add_to_end = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
List<AddedEditor> added_editors;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2021-08-22 03:52:44 +02:00
|
|
|
GDVIRTUAL1RC(bool, _can_handle, Variant)
|
2021-11-10 15:49:19 +01:00
|
|
|
GDVIRTUAL1(_parse_begin, Object *)
|
2021-08-22 03:52:44 +02:00
|
|
|
GDVIRTUAL2(_parse_category, Object *, String)
|
2021-11-10 15:49:19 +01:00
|
|
|
GDVIRTUAL2(_parse_group, Object *, String)
|
2021-08-22 03:52:44 +02:00
|
|
|
GDVIRTUAL7R(bool, _parse_property, Object *, int, String, int, String, int, bool)
|
2021-11-10 15:49:19 +01:00
|
|
|
GDVIRTUAL1(_parse_end, Object *)
|
2021-08-22 03:52:44 +02:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
public:
|
|
|
|
void add_custom_control(Control *control);
|
2022-05-24 00:35:01 +02:00
|
|
|
void add_property_editor(const String &p_for_property, Control *p_prop, bool p_add_to_end = false);
|
2018-05-15 22:12:35 +02:00
|
|
|
void add_property_editor_for_multiple_properties(const String &p_label, const Vector<String> &p_properties, Control *p_prop);
|
|
|
|
|
|
|
|
virtual bool can_handle(Object *p_object);
|
|
|
|
virtual void parse_begin(Object *p_object);
|
2021-11-10 15:49:19 +01:00
|
|
|
virtual void parse_category(Object *p_object, const String &p_category);
|
|
|
|
virtual void parse_group(Object *p_object, const String &p_group);
|
2021-07-01 03:24:34 +02:00
|
|
|
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false);
|
2021-11-10 15:49:19 +01:00
|
|
|
virtual void parse_end(Object *p_object);
|
2018-05-15 22:12:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class EditorInspectorCategory : public Control {
|
|
|
|
GDCLASS(EditorInspectorCategory, Control);
|
|
|
|
|
|
|
|
friend class EditorInspector;
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> icon;
|
2018-05-15 22:12:35 +02:00
|
|
|
String label;
|
2021-05-27 17:32:30 +02:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
|
|
|
virtual Control *make_custom_tooltip(const String &p_text) const override;
|
2018-07-20 23:14:33 +02:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
EditorInspectorCategory();
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorInspectorSection : public Container {
|
|
|
|
GDCLASS(EditorInspectorSection, Container);
|
|
|
|
|
|
|
|
String label;
|
|
|
|
String section;
|
2021-11-08 21:53:41 +01:00
|
|
|
bool vbox_added = false; // Optimization.
|
2018-05-15 22:12:35 +02:00
|
|
|
Color bg_color;
|
2021-11-08 21:53:41 +01:00
|
|
|
bool foldable = false;
|
|
|
|
int indent_depth = 0;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Timer *dropping_unfold_timer = nullptr;
|
2021-11-08 21:53:41 +01:00
|
|
|
bool dropping = false;
|
2022-12-16 15:14:50 +01:00
|
|
|
bool dropping_for_unfold = false;
|
2020-08-09 10:34:04 +02:00
|
|
|
|
2022-07-30 15:12:51 +02:00
|
|
|
HashSet<StringName> revertable_properties;
|
|
|
|
|
2018-07-19 00:37:17 +02:00
|
|
|
void _test_unfold();
|
2022-12-18 15:37:08 +01:00
|
|
|
int _get_header_height();
|
|
|
|
Ref<Texture2D> _get_arrow();
|
2018-07-19 00:37:17 +02:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
protected:
|
2021-11-08 21:53:41 +01:00
|
|
|
Object *object = nullptr;
|
2022-04-04 15:06:57 +02:00
|
|
|
VBoxContainer *vbox = nullptr;
|
2021-08-31 10:48:45 +02:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2021-08-22 17:37:22 +02:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
public:
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2021-11-08 21:53:41 +01:00
|
|
|
void setup(const String &p_section, const String &p_label, Object *p_object, const Color &p_bg_color, bool p_foldable, int p_indent_depth = 0);
|
2018-05-15 22:12:35 +02:00
|
|
|
VBoxContainer *get_vbox();
|
|
|
|
void unfold();
|
|
|
|
void fold();
|
|
|
|
|
2022-07-30 15:12:51 +02:00
|
|
|
bool has_revertable_properties() const;
|
|
|
|
void property_can_revert_changed(const String &p_path, bool p_can_revert);
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
EditorInspectorSection();
|
2018-07-19 00:37:17 +02:00
|
|
|
~EditorInspectorSection();
|
2018-05-15 22:12:35 +02:00
|
|
|
};
|
|
|
|
|
2021-08-31 10:48:45 +02:00
|
|
|
class EditorInspectorArray : public EditorInspectorSection {
|
|
|
|
GDCLASS(EditorInspectorArray, EditorInspectorSection);
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
MODE_NONE,
|
|
|
|
MODE_USE_COUNT_PROPERTY,
|
|
|
|
MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION,
|
|
|
|
} mode;
|
|
|
|
StringName count_property;
|
|
|
|
StringName array_element_prefix;
|
2022-07-21 01:18:14 +02:00
|
|
|
String swap_method;
|
2021-08-31 10:48:45 +02:00
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
VBoxContainer *elements_vbox = nullptr;
|
2021-08-31 10:48:45 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Control *control_dropping = nullptr;
|
2021-08-31 10:48:45 +02:00
|
|
|
bool dropping = false;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Button *add_button = nullptr;
|
2021-08-31 10:48:45 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
AcceptDialog *resize_dialog = nullptr;
|
2022-07-09 21:51:34 +02:00
|
|
|
SpinBox *new_size_spin_box = nullptr;
|
2021-08-31 10:48:45 +02:00
|
|
|
|
|
|
|
// Pagination
|
2022-02-06 01:11:15 +01:00
|
|
|
int page_length = 5;
|
2021-08-31 10:48:45 +02:00
|
|
|
int page = 0;
|
|
|
|
int max_page = 0;
|
|
|
|
int begin_array_index = 0;
|
|
|
|
int end_array_index = 0;
|
|
|
|
|
2022-09-06 17:59:36 +02:00
|
|
|
bool read_only = false;
|
2022-07-21 01:18:14 +02:00
|
|
|
bool movable = true;
|
|
|
|
bool numbered = false;
|
|
|
|
|
2021-08-31 10:48:45 +02:00
|
|
|
enum MenuOptions {
|
|
|
|
OPTION_MOVE_UP = 0,
|
|
|
|
OPTION_MOVE_DOWN,
|
|
|
|
OPTION_NEW_BEFORE,
|
|
|
|
OPTION_NEW_AFTER,
|
|
|
|
OPTION_REMOVE,
|
|
|
|
OPTION_CLEAR_ARRAY,
|
|
|
|
OPTION_RESIZE_ARRAY,
|
|
|
|
};
|
|
|
|
int popup_array_index_pressed = -1;
|
2022-04-04 15:06:57 +02:00
|
|
|
PopupMenu *rmb_popup = nullptr;
|
2021-08-31 10:48:45 +02:00
|
|
|
|
|
|
|
struct ArrayElement {
|
2022-04-04 15:06:57 +02:00
|
|
|
PanelContainer *panel = nullptr;
|
|
|
|
MarginContainer *margin = nullptr;
|
|
|
|
HBoxContainer *hbox = nullptr;
|
|
|
|
TextureRect *move_texture_rect = nullptr;
|
2022-07-21 01:18:14 +02:00
|
|
|
Label *number = nullptr;
|
2022-04-04 15:06:57 +02:00
|
|
|
VBoxContainer *vbox = nullptr;
|
2022-07-21 01:18:14 +02:00
|
|
|
Button *erase = nullptr;
|
2021-08-31 10:48:45 +02:00
|
|
|
};
|
|
|
|
LocalVector<ArrayElement> array_elements;
|
|
|
|
|
|
|
|
Ref<StyleBoxFlat> odd_style;
|
|
|
|
Ref<StyleBoxFlat> even_style;
|
|
|
|
|
|
|
|
int _get_array_count();
|
|
|
|
void _add_button_pressed();
|
2022-02-06 01:11:15 +01:00
|
|
|
void _paginator_page_changed(int p_page);
|
2021-08-31 10:48:45 +02:00
|
|
|
|
|
|
|
void _rmb_popup_id_pressed(int p_id);
|
|
|
|
|
|
|
|
void _control_dropping_draw();
|
|
|
|
|
|
|
|
void _vbox_visibility_changed();
|
|
|
|
|
|
|
|
void _panel_draw(int p_index);
|
|
|
|
void _panel_gui_input(Ref<InputEvent> p_event, int p_index);
|
|
|
|
void _move_element(int p_element_index, int p_to_pos);
|
|
|
|
void _clear_array();
|
|
|
|
void _resize_array(int p_size);
|
|
|
|
Array _extract_properties_as_array(const List<PropertyInfo> &p_list);
|
|
|
|
int _drop_position() const;
|
|
|
|
|
2022-07-09 21:51:34 +02:00
|
|
|
void _new_size_spin_box_value_changed(float p_value);
|
|
|
|
void _new_size_spin_box_text_submitted(String p_text);
|
2021-08-31 10:48:45 +02:00
|
|
|
void _resize_dialog_confirmed();
|
|
|
|
|
|
|
|
void _update_elements_visibility();
|
|
|
|
void _setup();
|
|
|
|
|
|
|
|
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
|
|
|
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
|
|
|
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
|
|
|
|
2022-07-21 01:18:14 +02:00
|
|
|
void _remove_item(int p_index);
|
|
|
|
|
2021-08-31 10:48:45 +02:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2022-07-21 01:18:14 +02:00
|
|
|
void setup_with_move_element_function(Object *p_object, String p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable = true, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = "");
|
|
|
|
void setup_with_count_property(Object *p_object, String p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable = true, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = "", const String &p_swap_method = "");
|
2021-08-31 10:48:45 +02:00
|
|
|
VBoxContainer *get_vbox(int p_index);
|
|
|
|
|
2022-09-06 17:59:36 +02:00
|
|
|
EditorInspectorArray(bool p_read_only);
|
2021-08-31 10:48:45 +02:00
|
|
|
};
|
|
|
|
|
2022-02-06 01:11:15 +01:00
|
|
|
class EditorPaginator : public HBoxContainer {
|
|
|
|
GDCLASS(EditorPaginator, HBoxContainer);
|
|
|
|
|
|
|
|
int page = 0;
|
|
|
|
int max_page = 0;
|
2022-04-04 15:06:57 +02:00
|
|
|
Button *first_page_button = nullptr;
|
|
|
|
Button *prev_page_button = nullptr;
|
|
|
|
LineEdit *page_line_edit = nullptr;
|
|
|
|
Label *page_count_label = nullptr;
|
|
|
|
Button *next_page_button = nullptr;
|
|
|
|
Button *last_page_button = nullptr;
|
2022-02-06 01:11:15 +01:00
|
|
|
|
|
|
|
void _first_page_button_pressed();
|
|
|
|
void _prev_page_button_pressed();
|
|
|
|
void _page_line_edit_text_submitted(String p_text);
|
|
|
|
void _next_page_button_pressed();
|
|
|
|
void _last_page_button_pressed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void update(int p_page, int p_max_page);
|
|
|
|
|
|
|
|
EditorPaginator();
|
|
|
|
};
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
class EditorInspector : public ScrollContainer {
|
|
|
|
GDCLASS(EditorInspector, ScrollContainer);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MAX_PLUGINS = 1024
|
|
|
|
};
|
|
|
|
static Ref<EditorInspectorPlugin> inspector_plugins[MAX_PLUGINS];
|
|
|
|
static int inspector_plugin_count;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
VBoxContainer *main_vbox = nullptr;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-03-28 22:37:01 +02:00
|
|
|
// Map used to cache the instantiated editors.
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, List<EditorProperty *>> editor_property_map;
|
2018-05-15 22:12:35 +02:00
|
|
|
List<EditorInspectorSection *> sections;
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<StringName> pending;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void _clear();
|
2022-04-04 15:06:57 +02:00
|
|
|
Object *object = nullptr;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
LineEdit *search_box = nullptr;
|
2022-02-15 15:56:58 +01:00
|
|
|
bool show_categories = false;
|
|
|
|
bool hide_script = true;
|
2022-03-23 21:08:54 +01:00
|
|
|
bool hide_metadata = true;
|
2022-02-15 15:56:58 +01:00
|
|
|
bool use_doc_hints = false;
|
2022-03-23 02:46:59 +01:00
|
|
|
EditorPropertyNameProcessor::Style property_name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED;
|
2022-02-15 15:56:58 +01:00
|
|
|
bool use_filter = false;
|
|
|
|
bool autoclear = false;
|
|
|
|
bool use_folding = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
int changing;
|
2022-02-15 15:56:58 +01:00
|
|
|
bool update_all_pending = false;
|
|
|
|
bool read_only = false;
|
|
|
|
bool keying = false;
|
|
|
|
bool sub_inspector = false;
|
|
|
|
bool wide_editors = false;
|
|
|
|
bool deletable_properties = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2018-07-05 01:08:45 +02:00
|
|
|
float refresh_countdown;
|
2022-02-15 15:56:58 +01:00
|
|
|
bool update_tree_pending = false;
|
2018-05-15 22:12:35 +02:00
|
|
|
StringName _prop_edited;
|
|
|
|
StringName property_selected;
|
|
|
|
int property_focusable;
|
2018-07-19 00:37:17 +02:00
|
|
|
int update_scroll_request;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-03-28 22:37:01 +02:00
|
|
|
struct PropertyDocInfo {
|
|
|
|
String description;
|
|
|
|
String path;
|
|
|
|
};
|
|
|
|
|
|
|
|
HashMap<StringName, HashMap<StringName, PropertyDocInfo>> doc_info_cache;
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, String> class_descr_cache;
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<StringName> restart_request_props;
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<ObjectID, int> scroll_cache;
|
2018-07-19 00:37:17 +02:00
|
|
|
|
2018-07-19 23:58:15 +02:00
|
|
|
String property_prefix; //used for sectioned inspector
|
|
|
|
String object_class;
|
2020-06-08 15:25:52 +02:00
|
|
|
Variant property_clipboard;
|
2018-07-19 23:58:15 +02:00
|
|
|
|
2021-02-17 17:44:49 +01:00
|
|
|
bool restrict_to_basic = false;
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
|
|
|
|
|
2021-08-30 18:59:45 +02:00
|
|
|
void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false, bool p_update_all = false);
|
2021-08-31 10:48:45 +02:00
|
|
|
void _multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing = false);
|
2018-11-08 21:46:34 +01:00
|
|
|
void _property_keyed(const String &p_path, bool p_advance);
|
|
|
|
void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance);
|
2020-04-17 04:52:00 +02:00
|
|
|
void _property_deleted(const String &p_path);
|
2018-05-15 22:12:35 +02:00
|
|
|
void _property_checked(const String &p_path, bool p_checked);
|
2021-10-26 21:12:25 +02:00
|
|
|
void _property_pinned(const String &p_path, bool p_pinned);
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2022-05-03 01:43:50 +02:00
|
|
|
void _resource_selected(const String &p_path, Ref<Resource> p_resource);
|
2018-05-15 22:12:35 +02:00
|
|
|
void _property_selected(const String &p_path, int p_focusable);
|
|
|
|
void _object_id_selected(const String &p_path, ObjectID p_id);
|
|
|
|
|
|
|
|
void _node_removed(Node *p_node);
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, int> per_array_page;
|
2021-08-31 10:48:45 +02:00
|
|
|
void _page_change_request(int p_new_page, const StringName &p_array_prefix);
|
|
|
|
|
2021-02-10 21:18:45 +01:00
|
|
|
void _changed_callback();
|
2019-06-26 15:08:25 +02:00
|
|
|
void _edit_request_change(Object *p_object, const String &p_prop);
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void _filter_changed(const String &p_text);
|
2022-07-30 15:12:51 +02:00
|
|
|
void _parse_added_editors(VBoxContainer *current_vbox, EditorInspectorSection *p_section, Ref<EditorInspectorPlugin> ped);
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2018-07-19 00:37:17 +02:00
|
|
|
void _vscroll_changed(double);
|
|
|
|
|
2019-04-09 00:18:03 +02:00
|
|
|
void _feature_profile_changed();
|
|
|
|
|
|
|
|
bool _is_property_disabled_by_feature_profile(const StringName &p_property);
|
|
|
|
|
2021-02-11 22:01:56 +01:00
|
|
|
void _update_inspector_bg();
|
|
|
|
|
2022-03-23 21:08:54 +01:00
|
|
|
ConfirmationDialog *add_meta_dialog = nullptr;
|
|
|
|
LineEdit *add_meta_name = nullptr;
|
|
|
|
OptionButton *add_meta_type = nullptr;
|
|
|
|
Label *add_meta_error = nullptr;
|
|
|
|
|
|
|
|
void _add_meta_confirm();
|
|
|
|
void _show_add_meta_dialog();
|
2022-03-27 23:38:00 +02:00
|
|
|
void _check_meta_name(const String &p_name);
|
2022-03-23 21:08:54 +01:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
|
|
|
|
static void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
|
|
|
|
static void cleanup_plugins();
|
2022-05-25 01:38:13 +02:00
|
|
|
static Button *create_inspector_action_button(const String &p_text);
|
2018-05-15 22:12:35 +02:00
|
|
|
|
2021-07-01 03:24:34 +02:00
|
|
|
static EditorProperty *instantiate_property_editor(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false);
|
2018-07-14 23:15:42 +02:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
String get_selected_path() const;
|
|
|
|
|
|
|
|
void update_tree();
|
|
|
|
void update_property(const String &p_prop);
|
|
|
|
void edit(Object *p_object);
|
2018-05-17 23:02:16 +02:00
|
|
|
Object *get_edited_object();
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void set_keying(bool p_active);
|
|
|
|
void set_read_only(bool p_read_only);
|
|
|
|
|
2022-03-23 02:46:59 +01:00
|
|
|
EditorPropertyNameProcessor::Style get_property_name_style() const;
|
|
|
|
void set_property_name_style(EditorPropertyNameProcessor::Style p_style);
|
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
void set_autoclear(bool p_enable);
|
|
|
|
|
|
|
|
void set_show_categories(bool p_show);
|
|
|
|
void set_use_doc_hints(bool p_enable);
|
2019-07-22 12:03:57 +02:00
|
|
|
void set_hide_script(bool p_hide);
|
2022-03-23 21:08:54 +01:00
|
|
|
void set_hide_metadata(bool p_hide);
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void set_use_filter(bool p_use);
|
|
|
|
void register_text_enter(Node *p_line_edit);
|
|
|
|
|
|
|
|
void set_use_folding(bool p_enable);
|
2018-06-14 20:36:38 +02:00
|
|
|
bool is_using_folding();
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void collapse_all_folding();
|
|
|
|
void expand_all_folding();
|
2022-07-30 15:12:51 +02:00
|
|
|
void expand_revertable();
|
2018-05-15 22:12:35 +02:00
|
|
|
|
|
|
|
void set_scroll_offset(int p_offset);
|
|
|
|
int get_scroll_offset() const;
|
|
|
|
|
2018-07-19 23:58:15 +02:00
|
|
|
void set_property_prefix(const String &p_prefix);
|
|
|
|
String get_property_prefix() const;
|
|
|
|
|
|
|
|
void set_object_class(const String &p_class);
|
|
|
|
String get_object_class() const;
|
|
|
|
|
2020-04-17 04:52:00 +02:00
|
|
|
void set_use_wide_editors(bool p_enable);
|
2019-01-25 19:14:56 +01:00
|
|
|
void set_sub_inspector(bool p_enable);
|
2021-02-11 22:01:56 +01:00
|
|
|
bool is_sub_inspector() const { return sub_inspector; }
|
2018-07-19 00:37:17 +02:00
|
|
|
|
2020-04-17 04:52:00 +02:00
|
|
|
void set_use_deletable_properties(bool p_enabled);
|
|
|
|
|
2021-02-17 17:44:49 +01:00
|
|
|
void set_restrict_to_basic_settings(bool p_restrict);
|
2020-06-08 15:25:52 +02:00
|
|
|
void set_property_clipboard(const Variant &p_value);
|
|
|
|
Variant get_property_clipboard() const;
|
2021-02-17 17:44:49 +01:00
|
|
|
|
2018-05-15 22:12:35 +02:00
|
|
|
EditorInspector();
|
|
|
|
};
|
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // EDITOR_INSPECTOR_H
|