1 /*************************************************************************/
2 /*  inspector_dock.h                                                     */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
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/animation_track_editor.h"
35 #include "editor/connections_dialog.h"
36 #include "editor/create_dialog.h"
37 #include "editor/editor_data.h"
38 #include "editor/editor_inspector.h"
39 #include "editor/editor_path.h"
40 #include "scene/gui/box_container.h"
41 #include "scene/gui/button.h"
42 #include "scene/gui/control.h"
43 #include "scene/gui/label.h"
44 #include "scene/gui/popup_menu.h"
45 #include "scene/gui/tool_button.h"
46 
47 class EditorNode;
48 
49 class InspectorDock : public VBoxContainer {
50 
51 	GDCLASS(InspectorDock, VBoxContainer);
52 
53 	enum MenuOptions {
54 		RESOURCE_LOAD,
55 		RESOURCE_SAVE,
56 		RESOURCE_SAVE_AS,
57 		RESOURCE_MAKE_BUILT_IN,
58 		RESOURCE_COPY,
59 		RESOURCE_EDIT_CLIPBOARD,
60 		OBJECT_COPY_PARAMS,
61 		OBJECT_PASTE_PARAMS,
62 		OBJECT_UNIQUE_RESOURCES,
63 		OBJECT_REQUEST_HELP,
64 
65 		COLLAPSE_ALL,
66 		EXPAND_ALL,
67 
68 		OBJECT_METHOD_BASE = 500
69 	};
70 
71 	EditorNode *editor;
72 	EditorData *editor_data;
73 
74 	EditorInspector *inspector;
75 
76 	Object *current;
77 
78 	ToolButton *backward_button;
79 	ToolButton *forward_button;
80 
81 	EditorFileDialog *load_resource_dialog;
82 	CreateDialog *new_resource_dialog;
83 	ToolButton *resource_new_button;
84 	ToolButton *resource_load_button;
85 	MenuButton *resource_save_button;
86 	MenuButton *history_menu;
87 	LineEdit *search;
88 
89 	MenuButton *object_menu;
90 	EditorPath *editor_path;
91 
92 	Button *warning;
93 	AcceptDialog *warning_dialog;
94 
95 	void _menu_option(int p_option);
96 
97 	void _new_resource();
98 	void _load_resource(const String &p_type = "");
_open_resource_selector()99 	void _open_resource_selector() { _load_resource(); }; // just used to call from arg-less signal
100 	void _resource_file_selected(String p_file);
101 	void _save_resource(bool save_as) const;
102 	void _unref_resource() const;
103 	void _copy_resource() const;
104 	void _paste_resource() const;
105 
106 	void _warning_pressed();
107 	void _resource_created() const;
108 	void _resource_selected(const RES &p_res, const String &p_property = "") const;
109 	void _edit_forward();
110 	void _edit_back();
111 	void _menu_collapseall();
112 	void _menu_expandall();
113 	void _select_history(int p_idx) const;
114 	void _prepare_history();
115 
116 	void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance);
117 	void _transform_keyed(Object *sp, const String &p_sub, const Transform &p_key);
118 
119 protected:
120 	static void _bind_methods();
121 	void _notification(int p_what);
122 
123 public:
124 	void go_back();
125 	void update_keying();
126 	void edit_resource(const Ref<Resource> &p_resource);
127 	void open_resource(const String &p_type);
128 	void clear();
129 	void set_warning(const String &p_message);
130 	void update(Object *p_object);
131 	Container *get_addon_area();
get_inspector()132 	EditorInspector *get_inspector() { return inspector; }
133 
134 	InspectorDock(EditorNode *p_editor, EditorData &p_editor_data);
135 	~InspectorDock();
136 };
137 
138 #endif
139