Debian Codegraph @

editor/inspector/editor_inspector.h

raw symbols SCIP
1 /**************************************************************************/
2 /* editor_inspector.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "editor/inspector/editor_property_name_processor.h"
34 #include "scene/gui/box_container.h"
35 #include "scene/gui/button.h"
36 #include "scene/gui/panel_container.h"
37 #include "scene/gui/scroll_container.h"
38
39 class AddMetadataDialog;
40 class AcceptDialog;
41 class EditorInspector;
42 class HSeparator;
43 class LineEdit;
44 class MarginContainer;
45 class OptionButton;
46 class PopupMenu;
47 class SpinBox;
48 class StyleBoxFlat;
49 class TextureRect;
50 class Timer;
51
52 class EditorPropertyRevert {
53 public:
54 static Variant get_property_revert_value(Object *p_object, const StringName &p_property, bool *r_is_valid);
55 static bool can_property_revert(Object *p_object, const StringName &p_property, const Variant *p_custom_current_value = nullptr);
56 };
57
58 class EditorInspectorActionButton : public Button {
59 GDCLASS(EditorInspectorActionButton, Button);
60
61 StringName icon_name;
62
63 protected:
64 void _notification(int p_what);
65
66 public:
67 EditorInspectorActionButton(const String &p_text, const StringName &p_icon_name);
68 };
69
70 class EditorProperty : public Container {
71 GDCLASS(EditorProperty, Container);
72
73 friend class EditorInspector;
74
75 struct ThemeCache {
76 Ref<Font> font;
77
78 Ref<StyleBox> background;
79 Ref<StyleBox> background_selected;
80 Ref<StyleBox> child_background;
81 Ref<StyleBox> hover;
82 Ref<StyleBox> sub_inspector_background[17];
83
84 Ref<Texture2D> key_icon;
85 Ref<Texture2D> key_next_icon;
86 Ref<Texture2D> delete_icon;
87 Ref<Texture2D> checked_icon;
88 Ref<Texture2D> unchecked_icon;
89 Ref<Texture2D> revert_icon;
90 Ref<Texture2D> pin_icon;
91 Ref<Texture2D> copy_icon;
92 Ref<Texture2D> copy_node_path_icon;
93 Ref<Texture2D> paste_icon;
94 Ref<Texture2D> unfavorite_icon;
95 Ref<Texture2D> favorite_icon;
96 Ref<Texture2D> override_icon;
97 Ref<Texture2D> remove_icon;
98 Ref<Texture2D> help_icon;
99
100 int font_size = 0;
101 int font_offset = 0;
102 int horizontal_separation = 0;
103 int vertical_separation = 0;
104 int padding = 0;
105 int inspector_property_height = 0;
106
107 Color property_color;
108 Color readonly_property_color;
109 Color warning_color;
110 Color readonly_warning_color;
111 Color property_color_x;
112 Color property_color_y;
113 Color property_color_z;
114 Color property_color_w;
115 Color sub_inspector_property_color;
116 } theme_cache;
117
118 public:
119 enum MenuItems {
120 MENU_COPY_VALUE,
121 MENU_PASTE_VALUE,
122 MENU_COPY_PROPERTY_PATH,
123 MENU_OVERRIDE_FOR_PROJECT,
124 MENU_FAVORITE_PROPERTY,
125 MENU_PIN_VALUE,
126 MENU_DELETE,
127 MENU_REVERT_VALUE,
128 MENU_OPEN_DOCUMENTATION,
129 };
130
131 enum ColorationMode {
132 COLORATION_CONTAINER_RESOURCE,
133 COLORATION_RESOURCE,
134 COLORATION_EXTERNAL,
135 };
136
137 enum InlineControlSide {
138 INLINE_CONTROL_LEFT,
139 INLINE_CONTROL_RIGHT
140 };
141
142 private:
143 String label;
144 int text_size;
145 friend class EditorInspector;
146 Object *object = nullptr;
147 StringName property;
148 String property_path;
149 String doc_path;
150 bool internal = false;
151 bool has_doc_tooltip = false;
152
153 int property_usage;
154
155 bool draw_label = true;
156 bool draw_background = true;
157 bool read_only = false;
158 bool checkable = false;
159 bool checked = false;
160 bool draw_warning = false;
161 bool draw_prop_warning = false;
162 bool keying = false;
163 bool deletable = false;
164 bool label_overlayed = false;
165
166 Rect2 right_child_rect;
167 Rect2 bottom_child_rect;
168
169 Rect2 keying_rect;
170 bool keying_hover = false;
171 Rect2 revert_rect;
172 bool revert_hover = false;
173 Rect2 check_rect;
174 bool check_hover = false;
175 Rect2 delete_rect;
176 bool delete_hover = false;
177
178 bool can_revert = false;
179 bool can_pin = false;
180 bool pin_hidden = false;
181 bool pinned = false;
182
183 bool can_favorite = false;
184 bool favorited = false;
185
186 bool use_folding = false;
187 bool draw_top_bg = true;
188
189 int sub_inspector_color_level = -1;
190
191 void _update_popup();
192 void _focusable_focused(int p_index);
193 int _get_v_separation() const { return bottom_editor ? 0 : theme_cache.vertical_separation; }
194
195 bool selectable = true;
196 bool selected = false;
197 int selected_focusable;
198
199 float split_ratio;
200
201 Vector<Control *> focusables;
202 Control *label_reference = nullptr;
203 Control *bottom_editor = nullptr;
204 PopupMenu *menu = nullptr;
205 HBoxContainer *left_container = nullptr;
206 HBoxContainer *right_container = nullptr;
207
208 HashMap<StringName, Variant> cache;
209
210 GDVIRTUAL0(_update_property)
211 GDVIRTUAL1(_set_read_only, bool)
212
213 void _update_flags();
214
215 protected:
216 bool has_borders = false;
217 bool can_override = false;
218
219 void _notification(int p_what);
220 static void _bind_methods();
221 virtual void _set_read_only(bool p_read_only);
222
223 virtual void gui_input(const Ref<InputEvent> &p_event) override;
224 virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
225 const Color *_get_property_colors();
226
227 virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const;
228 virtual StringName _get_revert_property() const;
229
230 void _update_property_bg();
231
232 void _accessibility_action_menu(const Variant &p_data);
233 void _accessibility_action_click(const Variant &p_data);
234
235 public:
236 void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false);
237
238 String get_tooltip_string(const String &p_string) const;
239
240 virtual Size2 get_minimum_size() const override;
241
242 void set_label(const String &p_label);
243 String get_label() const;
244
245 void set_read_only(bool p_read_only);
246 bool is_read_only() const;
247
248 void set_draw_label(bool p_draw_label);
249 bool is_draw_label() const;
250
251 void set_draw_background(bool p_draw_background);
252 bool is_draw_background() const;
253
254 Object *get_edited_object();
255 StringName get_edited_property() const;
256 inline Variant get_edited_property_value() const {
257 ERR_FAIL_NULL_V(object, Variant());
258 return object->get(property);
259 }
260 Variant get_edited_property_display_value() const;
261 EditorInspector *get_parent_inspector() const;
262
263 void set_doc_path(const String &p_doc_path);
264 void set_internal(bool p_internal);
265
266 virtual void update_property();
267 void update_editor_property_status();
268
269 virtual bool use_keying_next() const;
270
271 void set_checkable(bool p_checkable);
272 bool is_checkable() const;
273
274 void set_checked(bool p_checked);
275 bool is_checked() const;
276
277 void set_draw_warning(bool p_draw_warning);
278 bool is_draw_warning() const;
279
280 virtual void set_keying(bool p_keying);
281 bool is_keying() const;
282
283 virtual bool is_colored(ColorationMode p_mode) { return false; }
284
285 void set_deletable(bool p_enable);
286 bool is_deletable() const;
287 void add_focusable(Control *p_control);
288 void grab_focus(int p_focusable = -1);
289 void select(int p_focusable = -1);
290 void deselect();
291 bool is_selected() const;
292
293 void add_inline_control(Control *p_control, InlineControlSide p_side);
294 HBoxContainer *get_inline_container(InlineControlSide p_side);
295 void set_label_overlayed(bool p_overlay);
296
297 void set_label_reference(Control *p_control);
298 void set_bottom_editor(Control *p_control);
299
300 void set_use_folding(bool p_use_folding);
301 bool is_using_folding() const;
302
303 virtual void expand_all_folding();
304 virtual void collapse_all_folding();
305 virtual void expand_revertable();
306
307 virtual Variant get_drag_data(const Point2 &p_point) override;
308 virtual void update_cache();
309 virtual bool is_cache_valid() const;
310
311 void set_selectable(bool p_selectable);
312 bool is_selectable() const;
313
314 void set_name_split_ratio(float p_ratio);
315 float get_name_split_ratio() const;
316
317 void set_favoritable(bool p_favoritable);
318 bool is_favoritable() const;
319
320 void set_object_and_property(Object *p_object, const StringName &p_property);
321 virtual Control *make_custom_tooltip(const String &p_text) const override;
322
323 void set_draw_top_bg(bool p_draw) { draw_top_bg = p_draw; }
324
325 bool can_revert_to_default() const { return can_revert; }
326
327 void menu_option(int p_option);
328
329 EditorProperty();
330 };
331
332 class EditorInspectorPlugin : public RefCounted {
333 GDCLASS(EditorInspectorPlugin, RefCounted);
334
335 public:
336 friend class EditorInspector;
337 struct AddedEditor {
338 Control *property_editor = nullptr;
339 Vector<String> properties;
340 String label;
341 bool add_to_end = false;
342 };
343
344 List<AddedEditor> added_editors;
345
346 protected:
347 static void _bind_methods();
348
349 GDVIRTUAL1RC(bool, _can_handle, Object *)
350 GDVIRTUAL1(_parse_begin, Object *)
351 GDVIRTUAL2(_parse_category, Object *, String)
352 GDVIRTUAL2(_parse_group, Object *, String)
353 GDVIRTUAL7R(bool, _parse_property, Object *, Variant::Type, String, PropertyHint, String, BitField<PropertyUsageFlags>, bool)
354 GDVIRTUAL1(_parse_end, Object *)
355
356 #ifndef DISABLE_DEPRECATED
357 void _add_property_editor_bind_compat_92322(const String &p_for_property, Control *p_prop, bool p_add_to_end);
358 static void _bind_compatibility_methods();
359 #endif // DISABLE_DEPRECATED
360 public:
361 void add_custom_control(Control *control);
362 void add_property_editor(const String &p_for_property, Control *p_prop, bool p_add_to_end = false, const String &p_label = String());
363 void add_property_editor_for_multiple_properties(const String &p_label, const Vector<String> &p_properties, Control *p_prop);
364
365 virtual bool can_handle(Object *p_object);
366 virtual void parse_begin(Object *p_object);
367 virtual void parse_category(Object *p_object, const String &p_category);
368 virtual void parse_group(Object *p_object, const String &p_group);
369 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);
370 virtual void parse_end(Object *p_object);
371 };
372
373 class EditorInspectorCategory : public Control {
374 GDCLASS(EditorInspectorCategory, Control);
375
376 friend class EditorInspector;
377
378 // Right-click context menu options.
379 enum ClassMenuOption {
380 MENU_OPEN_DOCS,
381 MENU_UNFAVORITE_ALL,
382 };
383
384 struct ThemeCache {
385 int horizontal_separation = 0;
386 int vertical_separation = 0;
387 int class_icon_size = 0;
388
389 Color font_color;
390
391 Ref<Font> bold_font;
392 int bold_font_size = 0;
393
394 Ref<Texture2D> icon_favorites;
395 Ref<Texture2D> icon_unfavorite;
396 Ref<Texture2D> icon_help;
397
398 Ref<StyleBox> background;
399 } theme_cache;
400
401 PropertyInfo info;
402
403 Ref<Texture2D> icon;
404 String label;
405 String doc_class_name;
406 PopupMenu *menu = nullptr;
407 bool is_favorite = false;
408 bool menu_icon_dirty = true;
409
410 void _handle_menu_option(int p_option);
411 void _popup_context_menu(const Point2i &p_position);
412 void _update_icon();
413 void _theme_changed();
414
415 protected:
416 static void _bind_methods();
417
418 void _notification(int p_what);
419 virtual void gui_input(const Ref<InputEvent> &p_event) override;
420
421 void _accessibility_action_menu(const Variant &p_data);
422
423 public:
424 void set_as_favorite();
425 void set_property_info(const PropertyInfo &p_info);
426 void set_doc_class_name(const String &p_name);
427
428 virtual Size2 get_minimum_size() const override;
429 virtual Control *make_custom_tooltip(const String &p_text) const override;
430
431 EditorInspectorCategory();
432 };
433
434 class EditorInspectorSection : public Container {
435 GDCLASS(EditorInspectorSection, Container);
436
437 friend class EditorInspector;
438
439 String label;
440 String section;
441 Color bg_color;
442 bool vbox_added = false; // Optimization.
443 bool foldable = false;
444 bool checkable = false;
445 bool checked = false;
446 bool keying = false;
447 int indent_depth = 0;
448 int level = 1;
449 String related_enable_property;
450
451 Timer *dropping_unfold_timer = nullptr;
452 bool dropping_for_unfold = false;
453
454 Rect2 check_rect;
455 bool check_hover = false;
456 Rect2 keying_rect;
457 bool keying_hover = false;
458 bool header_hover = false;
459
460 bool checkbox_only = false;
461
462 HashSet<StringName> revertable_properties;
463
464 void _test_unfold();
465 int _get_header_height();
466 Ref<Texture2D> _get_arrow();
467 Ref<Texture2D> _get_checkbox();
468
469 EditorInspector *_get_parent_inspector() const;
470
471 struct ThemeCache {
472 int horizontal_separation = 0;
473 int vertical_separation = 0;
474 int inspector_margin = 0;
475 int indent_size = 0;
476 int key_padding_size = 0;
477
478 Color warning_color;
479 Color prop_subsection;
480 Color font_color;
481 Color font_disabled_color;
482 Color font_hover_color;
483 Color font_pressed_color;
484 Color font_hover_pressed_color;
485 Color font_hover_mono_color;
486
487 Ref<Font> font;
488 int font_size = 0;
489 Ref<Font> bold_font;
490 int bold_font_size = 0;
491 Ref<Font> light_font;
492 int light_font_size = 0;
493
494 Ref<Texture2D> arrow;
495 Ref<Texture2D> arrow_collapsed;
496 Ref<Texture2D> arrow_collapsed_mirrored;
497 Ref<Texture2D> icon_gui_checked;
498 Ref<Texture2D> icon_gui_unchecked;
499 Ref<Texture2D> icon_gui_animation_key;
500
501 Ref<StyleBoxFlat> indent_box;
502 Ref<StyleBoxFlat> key_hover;
503 } theme_cache;
504
505 protected:
506 Object *object = nullptr;
507 VBoxContainer *vbox = nullptr;
508
509 void _notification(int p_what);
510 static void _bind_methods();
511 virtual void gui_input(const Ref<InputEvent> &p_event) override;
512
513 void _accessibility_action_collapse(const Variant &p_data);
514 void _accessibility_action_expand(const Variant &p_data);
515
516 public:
517 virtual Size2 get_minimum_size() const override;
518 virtual Control *make_custom_tooltip(const String &p_text) const override;
519
520 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, int p_level = 1);
521 String get_section() const;
522 String get_label() const { return label; }
523 VBoxContainer *get_vbox();
524 void unfold();
525 void fold();
526 void set_bg_color(const Color &p_bg_color);
527 void reset_timer();
528 void set_checkable(const String &p_related_check_property, bool p_checkbox_only, bool p_checked);
529 inline bool is_checkable() const { return checkable; }
530 void set_checked(bool p_checked);
531 void set_keying(bool p_keying);
532
533 bool has_revertable_properties() const;
534 void property_can_revert_changed(const String &p_path, bool p_can_revert);
535 void _property_edited(const String &p_property);
536 void update_property();
537
538 EditorInspectorSection();
539 ~EditorInspectorSection();
540 };
541
542 class ArrayPanelContainer : public PanelContainer {
543 GDCLASS(ArrayPanelContainer, PanelContainer);
544
545 protected:
546 void _notification(int p_what);
547
548 void _accessibility_action_menu(const Variant &p_data);
549
550 public:
551 ArrayPanelContainer();
552 };
553
554 class EditorInspectorArray : public EditorInspectorSection {
555 GDCLASS(EditorInspectorArray, EditorInspectorSection);
556
557 enum Mode {
558 MODE_NONE,
559 MODE_USE_COUNT_PROPERTY,
560 MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION,
561 } mode = MODE_NONE;
562 StringName count_property;
563 StringName array_element_prefix;
564 String swap_method;
565
566 int count = 0;
567 int selected = -1;
568
569 VBoxContainer *elements_vbox = nullptr;
570
571 Control *control_dropping = nullptr;
572 bool dropping = false;
573
574 Button *add_button = nullptr;
575
576 AcceptDialog *resize_dialog = nullptr;
577 SpinBox *new_size_spin_box = nullptr;
578
579 // Pagination.
580 int page_length = 5;
581 int page = 0;
582 int max_page = 0;
583 int begin_array_index = 0;
584 int end_array_index = 0;
585
586 bool read_only = false;
587 bool movable = true;
588 bool is_const = false;
589 bool numbered = false;
590
591 enum MenuOptions {
592 OPTION_MOVE_UP = 0,
593 OPTION_MOVE_DOWN,
594 OPTION_NEW_BEFORE,
595 OPTION_NEW_AFTER,
596 OPTION_REMOVE,
597 OPTION_CLEAR_ARRAY,
598 OPTION_RESIZE_ARRAY,
599 };
600 int popup_array_index_pressed = -1;
601 PopupMenu *rmb_popup = nullptr;
602
603 struct ArrayElement {
604 PanelContainer *panel = nullptr;
605 MarginContainer *margin = nullptr;
606 HBoxContainer *hbox = nullptr;
607 Button *move_up = nullptr;
608 TextureRect *move_texture_rect = nullptr;
609 Button *move_down = nullptr;
610 Label *number = nullptr;
611 VBoxContainer *vbox = nullptr;
612 Button *erase = nullptr;
613 };
614 LocalVector<ArrayElement> array_elements;
615
616 Ref<StyleBoxFlat> odd_style;
617 Ref<StyleBoxFlat> even_style;
618
619 int _get_array_count();
620 void _add_button_pressed();
621 void _paginator_page_changed(int p_page);
622
623 void _rmb_popup_id_pressed(int p_id);
624
625 void _control_dropping_draw();
626
627 void _vbox_visibility_changed();
628
629 void _panel_draw(int p_index);
630 void _panel_gui_input(Ref<InputEvent> p_event, int p_index);
631 void _panel_gui_focus(int p_index);
632 void _panel_gui_unfocus(int p_index);
633 void _move_element(int p_element_index, int p_to_pos);
634 void _clear_array();
635 void _resize_array(int p_size);
636 Array _extract_properties_as_array(const List<PropertyInfo> &p_list);
637 int _drop_position() const;
638
639 void _new_size_spin_box_value_changed(float p_value);
640 void _new_size_spin_box_text_submitted(const String &p_text);
641 void _resize_dialog_confirmed();
642
643 void _update_elements_visibility();
644 void _setup();
645
646 Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
647 void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
648 bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
649
650 void _remove_item(int p_index);
651
652 protected:
653 void _notification(int p_what);
654 static void _bind_methods();
655
656 public:
657 void setup_with_move_element_function(Object *p_object, const 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_is_const = false, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = "");
658 void setup_with_count_property(Object *p_object, const 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_is_const = false, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = "", const String &p_swap_method = "");
659 VBoxContainer *get_vbox(int p_index);
660
661 void show_menu(int p_index, const Vector2 &p_offset);
662
663 EditorInspectorArray(bool p_read_only);
664 };
665
666 class EditorPaginator : public HBoxContainer {
667 GDCLASS(EditorPaginator, HBoxContainer);
668
669 int page = 0;
670 int max_page = 0;
671 Button *first_page_button = nullptr;
672 Button *prev_page_button = nullptr;
673 LineEdit *page_line_edit = nullptr;
674 Label *page_count_label = nullptr;
675 Button *next_page_button = nullptr;
676 Button *last_page_button = nullptr;
677
678 void _first_page_button_pressed();
679 void _prev_page_button_pressed();
680 void _page_line_edit_text_submitted(const String &p_text);
681 void _next_page_button_pressed();
682 void _last_page_button_pressed();
683
684 protected:
685 void _notification(int p_what);
686 static void _bind_methods();
687
688 public:
689 void update(int p_page, int p_max_page);
690
691 EditorPaginator();
692 };
693
694 class EditorInspector : public ScrollContainer {
695 GDCLASS(EditorInspector, ScrollContainer);
696
697 friend class EditorPropertyResource;
698
699 enum {
700 MAX_PLUGINS = 1024
701 };
702 static Ref<EditorInspectorPlugin> inspector_plugins[MAX_PLUGINS];
703 static int inspector_plugin_count;
704
705 struct ThemeCache {
706 Color prop_subsection;
707 } theme_cache;
708
709 EditorInspectorSection::ThemeCache section_theme_cache;
710 EditorInspectorCategory::ThemeCache category_theme_cache;
711 EditorProperty::ThemeCache property_theme_cache;
712
713 bool can_favorite = false;
714 PackedStringArray current_favorites;
715 VBoxContainer *favorites_section = nullptr;
716 VBoxContainer *favorites_vbox = nullptr;
717 VBoxContainer *favorites_groups_vbox = nullptr;
718 HSeparator *favorites_separator = nullptr;
719
720 EditorInspector *root_inspector = nullptr;
721
722 VBoxContainer *base_vbox = nullptr;
723 VBoxContainer *begin_vbox = nullptr;
724 VBoxContainer *main_vbox = nullptr;
725
726 // Map used to cache the instantiated editors.
727 HashMap<StringName, List<EditorProperty *>> editor_property_map;
728 List<EditorInspectorSection *> sections;
729 HashSet<StringName> pending;
730
731 void _clear(bool p_hide_plugins = true);
732 Object *object = nullptr;
733 Object *next_object = nullptr;
734
735 //
736
737 LineEdit *search_box = nullptr;
738 bool show_standard_categories = false;
739 bool show_custom_categories = false;
740 bool hide_script = true;
741 bool hide_metadata = true;
742 bool use_doc_hints = false;
743 EditorPropertyNameProcessor::Style property_name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED;
744 bool use_settings_name_style = true;
745 bool use_filter = false;
746 bool autoclear = false;
747 bool use_folding = false;
748 int changing;
749 bool update_all_pending = false;
750 bool read_only = false;
751 bool keying = false;
752 bool wide_editors = false;
753 bool deletable_properties = false;
754 bool mark_unsaved = true;
755
756 float refresh_countdown;
757 bool update_tree_pending = false;
758 StringName _prop_edited;
759 StringName property_selected;
760 int property_focusable;
761 int update_scroll_request;
762
763 bool updating_theme = false;
764
765 struct DocCacheInfo {
766 String doc_path;
767 String theme_item_name;
768 };
769
770 HashMap<StringName, HashMap<StringName, DocCacheInfo>> doc_cache;
771 HashSet<StringName> restart_request_props;
772 HashMap<String, String> custom_property_descriptions;
773 HashMap<String, String> doc_property_class_remaps;
774
775 HashMap<ObjectID, int> scroll_cache;
776
777 String property_prefix; // Used for sectioned inspector.
778 String object_class;
779
780 static inline Variant property_clipboard;
781
782 bool restrict_to_basic = false;
783
784 void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
785
786 void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false, bool p_update_all = false);
787 void _multiple_properties_changed(const Vector<String> &p_paths, const Array &p_values, bool p_changing = false);
788 void _property_keyed(const String &p_path, bool p_advance);
789 void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance);
790 void _property_deleted(const String &p_path);
791 void _property_checked(const String &p_path, bool p_checked);
792 void _property_pinned(const String &p_path, bool p_pinned);
793 bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style);
794 bool _resource_properties_matches(const Ref<Resource> &p_resource, const String &p_filter);
795
796 void _resource_selected(const String &p_path, Ref<Resource> p_resource);
797 void _property_selected(const String &p_path, int p_focusable);
798 void _object_id_selected(const String &p_path, ObjectID p_id);
799
800 void _update_current_favorites();
801 void _set_property_favorited(const String &p_path, bool p_favorited);
802 void _clear_current_favorites();
803
804 void _node_removed(Node *p_node);
805
806 HashMap<StringName, int> per_array_page;
807 void _page_change_request(int p_new_page, const StringName &p_array_prefix);
808
809 void _changed_callback();
810 void _edit_request_change(Object *p_object, const String &p_prop);
811
812 void _keying_changed();
813
814 void _parse_added_editors(VBoxContainer *p_current_vbox, EditorInspectorSection *p_section, Ref<EditorInspectorPlugin> p_plugin);
815
816 void _vscroll_changed(double);
817
818 void _feature_profile_changed();
819
820 bool _is_property_disabled_by_feature_profile(const StringName &p_property);
821
822 void _section_toggled_by_user(const String &p_path, bool p_value);
823
824 AddMetadataDialog *add_meta_dialog = nullptr;
825
826 void _add_meta_confirm();
827 void _show_add_meta_dialog();
828
829 void _handle_menu_option(int p_option);
830 void _add_section_in_tree(EditorInspectorSection *p_section, VBoxContainer *p_current_vbox);
831 static EditorInspector *_get_control_parent_inspector(Control *p_control);
832
833 protected:
834 static void _bind_methods();
835 void _notification(int p_what);
836
837 public:
838 static void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
839 static void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
840 static void cleanup_plugins();
841
842 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);
843
844 static void initialize_section_theme(EditorInspectorSection::ThemeCache &p_cache, Control *p_control);
845 static void initialize_category_theme(EditorInspectorCategory::ThemeCache &p_cache, Control *p_control);
846 static void initialize_property_theme(EditorProperty::ThemeCache &p_cache, Control *p_control);
847
848 static void set_property_clipboard(const Variant &p_value);
849 static Variant get_property_clipboard();
850
851 bool is_main_editor_inspector() const;
852 String get_selected_path() const;
853
854 void update_tree();
855 void update_property(const String &p_prop);
856 void edit(Object *p_object);
857 Object *get_edited_object();
858 Object *get_next_edited_object();
859
860 void set_keying(bool p_active);
861 void set_read_only(bool p_read_only);
862 void set_mark_unsaved(bool p_mark) { mark_unsaved = p_mark; }
863
864 EditorPropertyNameProcessor::Style get_property_name_style() const;
865 void set_property_name_style(EditorPropertyNameProcessor::Style p_style);
866
867 // If true, the inspector will update its property name style according to the current editor settings.
868 void set_use_settings_name_style(bool p_enable);
869
870 void set_autoclear(bool p_enable);
871
872 void set_show_categories(bool p_show_standard, bool p_show_custom);
873 void set_use_doc_hints(bool p_enable);
874 void set_hide_script(bool p_hide);
875 void set_hide_metadata(bool p_hide);
876
877 void set_use_filter(bool p_use);
878 void register_text_enter(Node *p_line_edit);
879
880 void set_use_folding(bool p_use_folding, bool p_update_tree = true);
881 bool is_using_folding();
882
883 void collapse_all_folding();
884 void expand_all_folding();
885 void expand_revertable();
886
887 void set_scroll_offset(int p_offset);
888 int get_scroll_offset() const;
889
890 void set_property_prefix(const String &p_prefix);
891 String get_property_prefix() const;
892
893 void add_custom_property_description(const String &p_class, const String &p_property, const String &p_description);
894 String get_custom_property_description(const String &p_property) const;
895
896 void remap_doc_property_class(const String &p_property_prefix, const String &p_class);
897
898 void set_object_class(const String &p_class);
899 String get_object_class() const;
900
901 void set_use_wide_editors(bool p_enable);
902 void set_root_inspector(EditorInspector *p_root_inspector);
903 EditorInspector *get_root_inspector() { return is_sub_inspector() ? root_inspector : this; }
904 bool is_sub_inspector() const { return root_inspector != nullptr; }
905
906 void set_use_deletable_properties(bool p_enabled);
907
908 void set_restrict_to_basic_settings(bool p_restrict);
909
910 EditorInspector();
911 };