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