2023-01-05 20:25:55 +08: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-17 01:19:33 +08:00
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
#ifndef EDITOR_INSPECTOR_H
|
|
|
|
#define EDITOR_INSPECTOR_H
|
|
|
|
|
2022-03-23 09:46:59 +08:00
|
|
|
#include "editor_property_name_processor.h"
|
2018-05-18 05:02:16 +08:00
|
|
|
#include "scene/gui/box_container.h"
|
2018-05-16 04:12:35 +08:00
|
|
|
#include "scene/gui/scroll_container.h"
|
2022-11-19 19:45:49 +08:00
|
|
|
|
|
|
|
class AcceptDialog;
|
|
|
|
class Button;
|
|
|
|
class ConfirmationDialog;
|
2023-02-16 01:03:12 +08:00
|
|
|
class EditorInspector;
|
2022-11-19 19:45:49 +08:00
|
|
|
class LineEdit;
|
|
|
|
class OptionButton;
|
|
|
|
class PanelContainer;
|
|
|
|
class PopupMenu;
|
|
|
|
class SpinBox;
|
|
|
|
class TextureRect;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2018-11-25 21:46:26 +08:00
|
|
|
class EditorPropertyRevert {
|
|
|
|
public:
|
2021-12-11 21:03:48 +08:00
|
|
|
static Variant get_property_revert_value(Object *p_object, const StringName &p_property, bool *r_is_valid);
|
2022-06-19 06:42:02 +08:00
|
|
|
static bool can_property_revert(Object *p_object, const StringName &p_property, const Variant *p_custom_current_value = nullptr);
|
2018-11-25 21:46:26 +08:00
|
|
|
};
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
class EditorProperty : public Container {
|
2019-03-20 02:35:57 +08:00
|
|
|
GDCLASS(EditorProperty, Container);
|
|
|
|
|
2020-06-08 21:25:52 +08:00
|
|
|
public:
|
|
|
|
enum MenuItems {
|
2022-09-30 22:44:27 +08:00
|
|
|
MENU_COPY_VALUE,
|
|
|
|
MENU_PASTE_VALUE,
|
2020-06-08 21:25:52 +08:00
|
|
|
MENU_COPY_PROPERTY_PATH,
|
2021-10-27 03:12:25 +08:00
|
|
|
MENU_PIN_VALUE,
|
2022-03-29 04:37:01 +08:00
|
|
|
MENU_OPEN_DOCUMENTATION,
|
2020-06-08 21:25:52 +08:00
|
|
|
};
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
private:
|
|
|
|
String label;
|
|
|
|
int text_size;
|
|
|
|
friend class EditorInspector;
|
2022-04-04 21:06:57 +08:00
|
|
|
Object *object = nullptr;
|
2018-05-16 04:12:35 +08:00
|
|
|
StringName property;
|
2022-03-13 21:23:44 +08:00
|
|
|
String property_path;
|
2022-03-29 04:37:01 +08:00
|
|
|
String doc_path;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
|
|
|
int property_usage;
|
|
|
|
|
2022-02-15 22:56:58 +08:00
|
|
|
bool read_only = false;
|
|
|
|
bool checkable = false;
|
|
|
|
bool checked = false;
|
|
|
|
bool draw_warning = false;
|
2023-03-09 16:41:52 +08:00
|
|
|
bool draw_prop_warning = false;
|
2022-02-15 22:56:58 +08:00
|
|
|
bool keying = false;
|
|
|
|
bool deletable = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2018-07-19 06:37:17 +08:00
|
|
|
Rect2 right_child_rect;
|
|
|
|
Rect2 bottom_child_rect;
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
Rect2 keying_rect;
|
2020-09-03 19:22:16 +08:00
|
|
|
bool keying_hover = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
Rect2 revert_rect;
|
2020-09-03 19:22:16 +08:00
|
|
|
bool revert_hover = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
Rect2 check_rect;
|
2020-09-03 19:22:16 +08:00
|
|
|
bool check_hover = false;
|
2020-04-17 10:52:00 +08:00
|
|
|
Rect2 delete_rect;
|
2020-09-03 19:22:16 +08:00
|
|
|
bool delete_hover = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-02-15 22:56:58 +08:00
|
|
|
bool can_revert = false;
|
|
|
|
bool can_pin = false;
|
|
|
|
bool pin_hidden = false;
|
|
|
|
bool pinned = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-02-15 22:56:58 +08:00
|
|
|
bool use_folding = false;
|
|
|
|
bool draw_top_bg = true;
|
2018-05-18 05:02:16 +08:00
|
|
|
|
2021-10-27 03:12:25 +08:00
|
|
|
void _update_popup();
|
2018-05-16 04:12:35 +08:00
|
|
|
void _focusable_focused(int p_index);
|
|
|
|
|
2022-02-15 22:56:58 +08:00
|
|
|
bool selectable = true;
|
|
|
|
bool selected = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
int selected_focusable;
|
|
|
|
|
2018-07-15 05:15:42 +08:00
|
|
|
float split_ratio;
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
Vector<Control *> focusables;
|
2022-04-04 21:06:57 +08:00
|
|
|
Control *label_reference = nullptr;
|
|
|
|
Control *bottom_editor = nullptr;
|
|
|
|
PopupMenu *menu = nullptr;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, Variant> cache;
|
2021-02-11 04:18:45 +08:00
|
|
|
|
2021-08-22 09:52:44 +08:00
|
|
|
GDVIRTUAL0(_update_property)
|
2022-09-19 07:21:55 +08:00
|
|
|
GDVIRTUAL1(_set_read_only, bool)
|
|
|
|
|
2021-10-27 03:12:25 +08:00
|
|
|
void _update_pin_flags();
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2021-08-16 10:42:24 +08:00
|
|
|
virtual void _set_read_only(bool p_read_only);
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2021-08-22 23:37:22 +08:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
2022-01-11 21:59:52 +08:00
|
|
|
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
|
2021-03-19 13:42:56 +08:00
|
|
|
const Color *_get_property_colors();
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-06-19 06:42:02 +08:00
|
|
|
virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const;
|
|
|
|
virtual StringName _get_revert_property() const;
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
public:
|
2019-01-19 00:01:24 +08:00
|
|
|
void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false);
|
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
2018-05-16 04:12:35 +08: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 06:42:02 +08:00
|
|
|
StringName get_edited_property() const;
|
2023-05-26 15:13:24 +08:00
|
|
|
inline Variant get_edited_property_value() const { return object->get(property); }
|
2023-02-16 01:03:12 +08:00
|
|
|
EditorInspector *get_parent_inspector() const;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-03-29 04:37:01 +08:00
|
|
|
void set_doc_path(const String &p_doc_path);
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
virtual void update_property();
|
2022-05-01 09:24:45 +08:00
|
|
|
void update_editor_property_status();
|
2018-05-16 04:12:35 +08: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 23:08:04 +08:00
|
|
|
void set_draw_warning(bool p_draw_warning);
|
|
|
|
bool is_draw_warning() const;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
|
|
|
void set_keying(bool p_keying);
|
|
|
|
bool is_keying() const;
|
|
|
|
|
2020-04-17 10:52:00 +08:00
|
|
|
void set_deletable(bool p_enable);
|
|
|
|
bool is_deletable() const;
|
2018-05-16 04:12:35 +08: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 21:08:25 +08:00
|
|
|
void set_bottom_editor(Control *p_control);
|
2018-05-18 05:02:16 +08: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 21:12:51 +08:00
|
|
|
virtual void expand_revertable();
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual Variant get_drag_data(const Point2 &p_point) override;
|
2021-02-11 04:18:45 +08:00
|
|
|
virtual void update_cache();
|
|
|
|
virtual bool is_cache_valid() const;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
void set_selectable(bool p_selectable);
|
|
|
|
bool is_selectable() const;
|
|
|
|
|
2018-07-15 05:15:42 +08:00
|
|
|
void set_name_split_ratio(float p_ratio);
|
|
|
|
float get_name_split_ratio() const;
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
void set_object_and_property(Object *p_object, const StringName &p_property);
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual Control *make_custom_tooltip(const String &p_text) const override;
|
2018-07-21 05:14:33 +08:00
|
|
|
|
2018-08-07 23:19:19 +08:00
|
|
|
void set_draw_top_bg(bool p_draw) { draw_top_bg = p_draw; }
|
|
|
|
|
2018-10-30 04:38:51 +08:00
|
|
|
bool can_revert_to_default() const { return can_revert; }
|
|
|
|
|
2020-06-08 21:25:52 +08:00
|
|
|
void menu_option(int p_option);
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
EditorProperty();
|
|
|
|
};
|
|
|
|
|
2021-06-05 00:03:15 +08:00
|
|
|
class EditorInspectorPlugin : public RefCounted {
|
|
|
|
GDCLASS(EditorInspectorPlugin, RefCounted);
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-05-24 06:35:01 +08:00
|
|
|
public:
|
2018-05-16 04:12:35 +08:00
|
|
|
friend class EditorInspector;
|
|
|
|
struct AddedEditor {
|
2020-11-24 17:12:55 +08:00
|
|
|
Control *property_editor = nullptr;
|
2018-05-16 04:12:35 +08:00
|
|
|
Vector<String> properties;
|
|
|
|
String label;
|
2022-05-24 06:35:01 +08:00
|
|
|
bool add_to_end = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
List<AddedEditor> added_editors;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2022-09-20 00:39:35 +08:00
|
|
|
GDVIRTUAL1RC(bool, _can_handle, Object *)
|
2021-11-10 22:49:19 +08:00
|
|
|
GDVIRTUAL1(_parse_begin, Object *)
|
2021-08-22 09:52:44 +08:00
|
|
|
GDVIRTUAL2(_parse_category, Object *, String)
|
2021-11-10 22:49:19 +08:00
|
|
|
GDVIRTUAL2(_parse_group, Object *, String)
|
2023-02-01 02:08:46 +08:00
|
|
|
GDVIRTUAL7R(bool, _parse_property, Object *, Variant::Type, String, PropertyHint, String, BitField<PropertyUsageFlags>, bool)
|
2021-11-10 22:49:19 +08:00
|
|
|
GDVIRTUAL1(_parse_end, Object *)
|
2021-08-22 09:52:44 +08:00
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
public:
|
|
|
|
void add_custom_control(Control *control);
|
2022-05-24 06:35:01 +08:00
|
|
|
void add_property_editor(const String &p_for_property, Control *p_prop, bool p_add_to_end = false);
|
2018-05-16 04:12:35 +08: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 22:49:19 +08:00
|
|
|
virtual void parse_category(Object *p_object, const String &p_category);
|
|
|
|
virtual void parse_group(Object *p_object, const String &p_group);
|
2023-02-01 02:08:46 +08: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 BitField<PropertyUsageFlags> p_usage, const bool p_wide = false);
|
2021-11-10 22:49:19 +08:00
|
|
|
virtual void parse_end(Object *p_object);
|
2018-05-16 04:12:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class EditorInspectorCategory : public Control {
|
|
|
|
GDCLASS(EditorInspectorCategory, Control);
|
|
|
|
|
|
|
|
friend class EditorInspector;
|
2019-06-12 02:43:37 +08:00
|
|
|
Ref<Texture2D> icon;
|
2018-05-16 04:12:35 +08:00
|
|
|
String label;
|
2021-05-27 23:32:30 +08:00
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
|
|
|
virtual Control *make_custom_tooltip(const String &p_text) const override;
|
2018-07-21 05:14:33 +08:00
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
EditorInspectorCategory();
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorInspectorSection : public Container {
|
|
|
|
GDCLASS(EditorInspectorSection, Container);
|
|
|
|
|
|
|
|
String label;
|
|
|
|
String section;
|
2021-11-09 04:53:41 +08:00
|
|
|
bool vbox_added = false; // Optimization.
|
2018-05-16 04:12:35 +08:00
|
|
|
Color bg_color;
|
2021-11-09 04:53:41 +08:00
|
|
|
bool foldable = false;
|
|
|
|
int indent_depth = 0;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
Timer *dropping_unfold_timer = nullptr;
|
2021-11-09 04:53:41 +08:00
|
|
|
bool dropping = false;
|
2022-12-16 22:14:50 +08:00
|
|
|
bool dropping_for_unfold = false;
|
2020-08-09 16:34:04 +08:00
|
|
|
|
2022-07-30 21:12:51 +08:00
|
|
|
HashSet<StringName> revertable_properties;
|
|
|
|
|
2018-07-19 06:37:17 +08:00
|
|
|
void _test_unfold();
|
2022-12-18 22:37:08 +08:00
|
|
|
int _get_header_height();
|
|
|
|
Ref<Texture2D> _get_arrow();
|
2018-07-19 06:37:17 +08:00
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
protected:
|
2021-11-09 04:53:41 +08:00
|
|
|
Object *object = nullptr;
|
2022-04-04 21:06:57 +08:00
|
|
|
VBoxContainer *vbox = nullptr;
|
2021-08-31 16:48:45 +08:00
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2021-08-22 23:37:22 +08:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
|
|
|
public:
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2021-11-09 04:53:41 +08: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-16 04:12:35 +08:00
|
|
|
VBoxContainer *get_vbox();
|
|
|
|
void unfold();
|
|
|
|
void fold();
|
2023-05-15 01:40:45 +08:00
|
|
|
void set_bg_color(const Color &p_bg_color);
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-07-30 21:12:51 +08:00
|
|
|
bool has_revertable_properties() const;
|
|
|
|
void property_can_revert_changed(const String &p_path, bool p_can_revert);
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
EditorInspectorSection();
|
2018-07-19 06:37:17 +08:00
|
|
|
~EditorInspectorSection();
|
2018-05-16 04:12:35 +08:00
|
|
|
};
|
|
|
|
|
2021-08-31 16:48:45 +08: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 07:18:14 +08:00
|
|
|
String swap_method;
|
2021-08-31 16:48:45 +08:00
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
VBoxContainer *elements_vbox = nullptr;
|
2021-08-31 16:48:45 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
Control *control_dropping = nullptr;
|
2021-08-31 16:48:45 +08:00
|
|
|
bool dropping = false;
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
Button *add_button = nullptr;
|
2021-08-31 16:48:45 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
AcceptDialog *resize_dialog = nullptr;
|
2022-07-10 03:51:34 +08:00
|
|
|
SpinBox *new_size_spin_box = nullptr;
|
2021-08-31 16:48:45 +08:00
|
|
|
|
2023-01-30 05:24:41 +08:00
|
|
|
// Pagination.
|
2022-02-06 08:11:15 +08:00
|
|
|
int page_length = 5;
|
2021-08-31 16:48:45 +08:00
|
|
|
int page = 0;
|
|
|
|
int max_page = 0;
|
|
|
|
int begin_array_index = 0;
|
|
|
|
int end_array_index = 0;
|
|
|
|
|
2022-09-06 23:59:36 +08:00
|
|
|
bool read_only = false;
|
2022-07-21 07:18:14 +08:00
|
|
|
bool movable = true;
|
|
|
|
bool numbered = false;
|
|
|
|
|
2021-08-31 16:48:45 +08: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 21:06:57 +08:00
|
|
|
PopupMenu *rmb_popup = nullptr;
|
2021-08-31 16:48:45 +08:00
|
|
|
|
|
|
|
struct ArrayElement {
|
2022-04-04 21:06:57 +08:00
|
|
|
PanelContainer *panel = nullptr;
|
|
|
|
MarginContainer *margin = nullptr;
|
|
|
|
HBoxContainer *hbox = nullptr;
|
|
|
|
TextureRect *move_texture_rect = nullptr;
|
2022-07-21 07:18:14 +08:00
|
|
|
Label *number = nullptr;
|
2022-04-04 21:06:57 +08:00
|
|
|
VBoxContainer *vbox = nullptr;
|
2022-07-21 07:18:14 +08:00
|
|
|
Button *erase = nullptr;
|
2021-08-31 16:48:45 +08:00
|
|
|
};
|
|
|
|
LocalVector<ArrayElement> array_elements;
|
|
|
|
|
|
|
|
Ref<StyleBoxFlat> odd_style;
|
|
|
|
Ref<StyleBoxFlat> even_style;
|
|
|
|
|
|
|
|
int _get_array_count();
|
|
|
|
void _add_button_pressed();
|
2022-02-06 08:11:15 +08:00
|
|
|
void _paginator_page_changed(int p_page);
|
2021-08-31 16:48:45 +08: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-10 03:51:34 +08:00
|
|
|
void _new_size_spin_box_value_changed(float p_value);
|
|
|
|
void _new_size_spin_box_text_submitted(String p_text);
|
2021-08-31 16:48:45 +08: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 07:18:14 +08:00
|
|
|
void _remove_item(int p_index);
|
|
|
|
|
2021-08-31 16:48:45 +08:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2022-07-21 07:18:14 +08: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 16:48:45 +08:00
|
|
|
VBoxContainer *get_vbox(int p_index);
|
|
|
|
|
2022-09-06 23:59:36 +08:00
|
|
|
EditorInspectorArray(bool p_read_only);
|
2021-08-31 16:48:45 +08:00
|
|
|
};
|
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
class EditorPaginator : public HBoxContainer {
|
|
|
|
GDCLASS(EditorPaginator, HBoxContainer);
|
|
|
|
|
|
|
|
int page = 0;
|
|
|
|
int max_page = 0;
|
2022-04-04 21:06:57 +08: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 08:11:15 +08: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-16 04:12:35 +08: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 21:06:57 +08:00
|
|
|
VBoxContainer *main_vbox = nullptr;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-03-29 04:37:01 +08:00
|
|
|
// Map used to cache the instantiated editors.
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, List<EditorProperty *>> editor_property_map;
|
2018-05-16 04:12:35 +08:00
|
|
|
List<EditorInspectorSection *> sections;
|
2022-05-19 23:00:06 +08:00
|
|
|
HashSet<StringName> pending;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2023-02-11 21:08:39 +08:00
|
|
|
void _clear(bool p_hide_plugins = true);
|
2022-04-04 21:06:57 +08:00
|
|
|
Object *object = nullptr;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
LineEdit *search_box = nullptr;
|
2022-02-15 22:56:58 +08:00
|
|
|
bool show_categories = false;
|
|
|
|
bool hide_script = true;
|
2022-03-24 04:08:54 +08:00
|
|
|
bool hide_metadata = true;
|
2022-02-15 22:56:58 +08:00
|
|
|
bool use_doc_hints = false;
|
2022-03-23 09:46:59 +08:00
|
|
|
EditorPropertyNameProcessor::Style property_name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED;
|
2023-03-02 20:37:02 +08:00
|
|
|
bool use_settings_name_style = true;
|
2022-02-15 22:56:58 +08:00
|
|
|
bool use_filter = false;
|
|
|
|
bool autoclear = false;
|
|
|
|
bool use_folding = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
int changing;
|
2022-02-15 22:56:58 +08: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-16 04:12:35 +08:00
|
|
|
|
2018-07-05 07:08:45 +08:00
|
|
|
float refresh_countdown;
|
2022-02-15 22:56:58 +08:00
|
|
|
bool update_tree_pending = false;
|
2018-05-16 04:12:35 +08:00
|
|
|
StringName _prop_edited;
|
|
|
|
StringName property_selected;
|
|
|
|
int property_focusable;
|
2018-07-19 06:37:17 +08:00
|
|
|
int update_scroll_request;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-03-29 04:37:01 +08:00
|
|
|
struct PropertyDocInfo {
|
|
|
|
String description;
|
|
|
|
String path;
|
|
|
|
};
|
|
|
|
|
|
|
|
HashMap<StringName, HashMap<StringName, PropertyDocInfo>> doc_info_cache;
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, String> class_descr_cache;
|
2022-05-19 23:00:06 +08:00
|
|
|
HashSet<StringName> restart_request_props;
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<ObjectID, int> scroll_cache;
|
2018-07-19 06:37:17 +08:00
|
|
|
|
2023-01-30 05:24:41 +08:00
|
|
|
String property_prefix; // Used for sectioned inspector.
|
2018-07-20 05:58:15 +08:00
|
|
|
String object_class;
|
2020-06-08 21:25:52 +08:00
|
|
|
Variant property_clipboard;
|
2018-07-20 05:58:15 +08:00
|
|
|
|
2021-02-18 00:44:49 +08:00
|
|
|
bool restrict_to_basic = false;
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
|
|
|
|
|
2021-08-31 00:59:45 +08: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 16:48:45 +08:00
|
|
|
void _multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing = false);
|
2018-11-09 04:46:34 +08: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 10:52:00 +08:00
|
|
|
void _property_deleted(const String &p_path);
|
2018-05-16 04:12:35 +08:00
|
|
|
void _property_checked(const String &p_path, bool p_checked);
|
2021-10-27 03:12:25 +08:00
|
|
|
void _property_pinned(const String &p_path, bool p_pinned);
|
2023-05-17 23:22:26 +08:00
|
|
|
bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style);
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2022-05-03 07:43:50 +08:00
|
|
|
void _resource_selected(const String &p_path, Ref<Resource> p_resource);
|
2018-05-16 04:12:35 +08: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 21:04:37 +08:00
|
|
|
HashMap<StringName, int> per_array_page;
|
2021-08-31 16:48:45 +08:00
|
|
|
void _page_change_request(int p_new_page, const StringName &p_array_prefix);
|
|
|
|
|
2021-02-11 04:18:45 +08:00
|
|
|
void _changed_callback();
|
2019-06-26 21:08:25 +08:00
|
|
|
void _edit_request_change(Object *p_object, const String &p_prop);
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2023-03-08 01:41:54 +08:00
|
|
|
void _keying_changed();
|
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
void _filter_changed(const String &p_text);
|
2022-07-30 21:12:51 +08:00
|
|
|
void _parse_added_editors(VBoxContainer *current_vbox, EditorInspectorSection *p_section, Ref<EditorInspectorPlugin> ped);
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2018-07-19 06:37:17 +08:00
|
|
|
void _vscroll_changed(double);
|
|
|
|
|
2019-04-09 06:18:03 +08:00
|
|
|
void _feature_profile_changed();
|
|
|
|
|
|
|
|
bool _is_property_disabled_by_feature_profile(const StringName &p_property);
|
|
|
|
|
2021-02-12 05:01:56 +08:00
|
|
|
void _update_inspector_bg();
|
|
|
|
|
2022-03-24 04:08:54 +08:00
|
|
|
ConfirmationDialog *add_meta_dialog = nullptr;
|
|
|
|
LineEdit *add_meta_name = nullptr;
|
|
|
|
OptionButton *add_meta_type = nullptr;
|
2023-05-03 05:59:00 +08:00
|
|
|
PanelContainer *add_meta_error_panel = nullptr;
|
2022-03-24 04:08:54 +08:00
|
|
|
Label *add_meta_error = nullptr;
|
|
|
|
|
|
|
|
void _add_meta_confirm();
|
|
|
|
void _show_add_meta_dialog();
|
2022-03-28 05:38:00 +08:00
|
|
|
void _check_meta_name(const String &p_name);
|
2022-03-24 04:08:54 +08:00
|
|
|
|
2018-05-16 04:12:35 +08: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 07:38:13 +08:00
|
|
|
static Button *create_inspector_action_button(const String &p_text);
|
2018-05-16 04:12:35 +08:00
|
|
|
|
2021-07-01 09:24:34 +08: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-15 05:15:42 +08:00
|
|
|
|
2023-02-16 01:03:12 +08:00
|
|
|
bool is_main_editor_inspector() const;
|
2018-05-16 04:12:35 +08:00
|
|
|
String get_selected_path() const;
|
|
|
|
|
|
|
|
void update_tree();
|
|
|
|
void update_property(const String &p_prop);
|
|
|
|
void edit(Object *p_object);
|
2018-05-18 05:02:16 +08:00
|
|
|
Object *get_edited_object();
|
2018-05-16 04:12:35 +08:00
|
|
|
|
|
|
|
void set_keying(bool p_active);
|
|
|
|
void set_read_only(bool p_read_only);
|
|
|
|
|
2022-03-23 09:46:59 +08:00
|
|
|
EditorPropertyNameProcessor::Style get_property_name_style() const;
|
|
|
|
void set_property_name_style(EditorPropertyNameProcessor::Style p_style);
|
|
|
|
|
2023-03-02 20:37:02 +08:00
|
|
|
// If true, the inspector will update its property name style according to the current editor settings.
|
|
|
|
void set_use_settings_name_style(bool p_enable);
|
|
|
|
|
2018-05-16 04:12:35 +08: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 18:03:57 +08:00
|
|
|
void set_hide_script(bool p_hide);
|
2022-03-24 04:08:54 +08:00
|
|
|
void set_hide_metadata(bool p_hide);
|
2018-05-16 04:12:35 +08: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-15 02:36:38 +08:00
|
|
|
bool is_using_folding();
|
2018-05-16 04:12:35 +08:00
|
|
|
|
|
|
|
void collapse_all_folding();
|
|
|
|
void expand_all_folding();
|
2022-07-30 21:12:51 +08:00
|
|
|
void expand_revertable();
|
2018-05-16 04:12:35 +08:00
|
|
|
|
|
|
|
void set_scroll_offset(int p_offset);
|
|
|
|
int get_scroll_offset() const;
|
|
|
|
|
2018-07-20 05:58:15 +08: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 10:52:00 +08:00
|
|
|
void set_use_wide_editors(bool p_enable);
|
2019-01-26 02:14:56 +08:00
|
|
|
void set_sub_inspector(bool p_enable);
|
2021-02-12 05:01:56 +08:00
|
|
|
bool is_sub_inspector() const { return sub_inspector; }
|
2018-07-19 06:37:17 +08:00
|
|
|
|
2020-04-17 10:52:00 +08:00
|
|
|
void set_use_deletable_properties(bool p_enabled);
|
|
|
|
|
2021-02-18 00:44:49 +08:00
|
|
|
void set_restrict_to_basic_settings(bool p_restrict);
|
2020-06-08 21:25:52 +08:00
|
|
|
void set_property_clipboard(const Variant &p_value);
|
|
|
|
Variant get_property_clipboard() const;
|
2021-02-18 00:44:49 +08:00
|
|
|
|
2018-05-16 04:12:35 +08:00
|
|
|
EditorInspector();
|
|
|
|
};
|
|
|
|
|
2022-07-24 05:41:51 +08:00
|
|
|
#endif // EDITOR_INSPECTOR_H
|