inspector_dock.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /**************************************************************************/
  2. /* inspector_dock.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. #ifndef INSPECTOR_DOCK_H
  31. #define INSPECTOR_DOCK_H
  32. #include "editor/create_dialog.h"
  33. #include "editor/editor_data.h"
  34. #include "editor/editor_inspector.h"
  35. #include "scene/gui/box_container.h"
  36. #include "scene/gui/button.h"
  37. #include "scene/gui/dialogs.h"
  38. #include "scene/gui/line_edit.h"
  39. #include "scene/gui/menu_button.h"
  40. #include "scene/gui/tree.h"
  41. class EditorFileDialog;
  42. class EditorObjectSelector;
  43. class InspectorDock : public VBoxContainer {
  44. GDCLASS(InspectorDock, VBoxContainer);
  45. enum MenuOptions {
  46. RESOURCE_LOAD,
  47. RESOURCE_SAVE,
  48. RESOURCE_SAVE_AS,
  49. RESOURCE_SHOW_IN_FILESYSTEM,
  50. RESOURCE_MAKE_BUILT_IN,
  51. RESOURCE_COPY,
  52. RESOURCE_EDIT_CLIPBOARD,
  53. OBJECT_COPY_PARAMS,
  54. OBJECT_PASTE_PARAMS,
  55. OBJECT_UNIQUE_RESOURCES,
  56. OBJECT_REQUEST_HELP,
  57. COLLAPSE_ALL,
  58. EXPAND_ALL,
  59. EXPAND_REVERTABLE,
  60. // Matches `EditorPropertyNameProcessor::Style`.
  61. PROPERTY_NAME_STYLE_RAW,
  62. PROPERTY_NAME_STYLE_CAPITALIZED,
  63. PROPERTY_NAME_STYLE_LOCALIZED,
  64. OBJECT_METHOD_BASE = 500
  65. };
  66. EditorData *editor_data = nullptr;
  67. EditorInspector *inspector = nullptr;
  68. Object *current = nullptr;
  69. Button *backward_button = nullptr;
  70. Button *forward_button = nullptr;
  71. EditorFileDialog *load_resource_dialog = nullptr;
  72. CreateDialog *new_resource_dialog = nullptr;
  73. Button *resource_new_button = nullptr;
  74. Button *resource_load_button = nullptr;
  75. MenuButton *resource_save_button = nullptr;
  76. MenuButton *resource_extra_button = nullptr;
  77. MenuButton *history_menu = nullptr;
  78. LineEdit *search = nullptr;
  79. Button *open_docs_button = nullptr;
  80. MenuButton *object_menu = nullptr;
  81. EditorObjectSelector *object_selector = nullptr;
  82. bool info_is_warning = false; // Display in yellow and use warning icon if true.
  83. Button *info = nullptr;
  84. AcceptDialog *info_dialog = nullptr;
  85. int current_option = -1;
  86. ConfirmationDialog *unique_resources_confirmation = nullptr;
  87. Label *unique_resources_label = nullptr;
  88. Tree *unique_resources_list_tree = nullptr;
  89. EditorPropertyNameProcessor::Style property_name_style;
  90. List<Pair<StringName, Variant>> stored_properties;
  91. void _prepare_menu();
  92. void _menu_option(int p_option);
  93. void _menu_confirm_current();
  94. void _menu_option_confirm(int p_option, bool p_confirmed);
  95. void _new_resource();
  96. void _load_resource(const String &p_type = "");
  97. void _open_resource_selector() { _load_resource(); } // just used to call from arg-less signal
  98. void _resource_file_selected(const String &p_file);
  99. void _save_resource(bool save_as);
  100. void _unref_resource();
  101. void _copy_resource();
  102. void _paste_resource();
  103. void _prepare_resource_extra_popup();
  104. Ref<Resource> _get_current_resource() const;
  105. void _info_pressed();
  106. void _resource_created();
  107. void _resource_selected(const Ref<Resource> &p_res, const String &p_property);
  108. void _edit_forward();
  109. void _edit_back();
  110. void _menu_collapseall();
  111. void _menu_expandall();
  112. void _menu_expand_revertable();
  113. void _select_history(int p_idx);
  114. void _prepare_history();
  115. virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
  116. private:
  117. static InspectorDock *singleton;
  118. public:
  119. static InspectorDock *get_singleton() { return singleton; }
  120. static EditorInspector *get_inspector_singleton() { return singleton->inspector; }
  121. protected:
  122. static void _bind_methods();
  123. void _notification(int p_what);
  124. public:
  125. void go_back();
  126. void edit_resource(const Ref<Resource> &p_resource);
  127. void open_resource(const String &p_type);
  128. void clear();
  129. void set_info(const String &p_button_text, const String &p_message, bool p_is_warning);
  130. void update(Object *p_object);
  131. Container *get_addon_area();
  132. EditorInspector *get_inspector() { return inspector; }
  133. EditorPropertyNameProcessor::Style get_property_name_style() const;
  134. void store_script_properties(Object *p_object);
  135. void apply_script_properties(Object *p_object);
  136. InspectorDock(EditorData &p_editor_data);
  137. ~InspectorDock();
  138. };
  139. #endif // INSPECTOR_DOCK_H