inspector_dock.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*************************************************************************/
  2. /* inspector_dock.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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. #include "inspector_dock.h"
  31. #include "editor/editor_node.h"
  32. #include "editor/editor_settings.h"
  33. #include "editor/plugins/animation_player_editor_plugin.h"
  34. void InspectorDock::_menu_option(int p_option) {
  35. switch (p_option) {
  36. case EXPAND_ALL: {
  37. _menu_expandall();
  38. } break;
  39. case COLLAPSE_ALL: {
  40. _menu_collapseall();
  41. } break;
  42. case RESOURCE_MAKE_BUILT_IN: {
  43. _unref_resource();
  44. } break;
  45. case RESOURCE_COPY: {
  46. _copy_resource();
  47. } break;
  48. case RESOURCE_EDIT_CLIPBOARD: {
  49. _paste_resource();
  50. } break;
  51. case RESOURCE_SAVE: {
  52. _save_resource(false);
  53. } break;
  54. case RESOURCE_SAVE_AS: {
  55. _save_resource(true);
  56. } break;
  57. case OBJECT_REQUEST_HELP: {
  58. if (current) {
  59. editor->set_visible_editor(EditorNode::EDITOR_SCRIPT);
  60. emit_signal("request_help", current->get_class());
  61. }
  62. } break;
  63. case OBJECT_COPY_PARAMS: {
  64. editor_data->apply_changes_in_editors();
  65. if (current)
  66. editor_data->copy_object_params(current);
  67. } break;
  68. case OBJECT_PASTE_PARAMS: {
  69. editor_data->apply_changes_in_editors();
  70. if (current)
  71. editor_data->paste_object_params(current);
  72. } break;
  73. case OBJECT_UNIQUE_RESOURCES: {
  74. editor_data->apply_changes_in_editors();
  75. if (current) {
  76. List<PropertyInfo> props;
  77. current->get_property_list(&props);
  78. Map<RES, RES> duplicates;
  79. for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
  80. if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
  81. continue;
  82. Variant v = current->get(E->get().name);
  83. if (v.is_ref()) {
  84. REF ref = v;
  85. if (ref.is_valid()) {
  86. RES res = ref;
  87. if (res.is_valid()) {
  88. if (!duplicates.has(res)) {
  89. duplicates[res] = res->duplicate();
  90. }
  91. res = duplicates[res];
  92. current->set(E->get().name, res);
  93. editor->get_inspector()->update_property(E->get().name);
  94. }
  95. }
  96. }
  97. }
  98. }
  99. editor_data->get_undo_redo().clear_history();
  100. editor->get_editor_plugins_over()->edit(NULL);
  101. editor->get_editor_plugins_over()->edit(current);
  102. } break;
  103. default: {
  104. if (p_option >= OBJECT_METHOD_BASE) {
  105. ERR_FAIL_COND(!current);
  106. int idx = p_option - OBJECT_METHOD_BASE;
  107. List<MethodInfo> methods;
  108. current->get_method_list(&methods);
  109. ERR_FAIL_INDEX(idx, methods.size());
  110. String name = methods[idx].name;
  111. current->call(name);
  112. }
  113. }
  114. }
  115. }
  116. void InspectorDock::_new_resource() {
  117. new_resource_dialog->popup_create(true);
  118. }
  119. void InspectorDock::_load_resource(const String &p_type) {
  120. load_resource_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
  121. List<String> extensions;
  122. ResourceLoader::get_recognized_extensions_for_type(p_type, &extensions);
  123. load_resource_dialog->clear_filters();
  124. for (int i = 0; i < extensions.size(); i++) {
  125. load_resource_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
  126. }
  127. load_resource_dialog->popup_centered_ratio();
  128. }
  129. void InspectorDock::_resource_file_selected(String p_file) {
  130. RES res = ResourceLoader::load(p_file);
  131. if (res.is_null()) {
  132. warning_dialog->set_text(TTR("Failed to load resource."));
  133. return;
  134. };
  135. editor->push_item(res.operator->());
  136. }
  137. void InspectorDock::_save_resource(bool save_as) const {
  138. uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
  139. Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
  140. ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
  141. RES current_res = RES(Object::cast_to<Resource>(current_obj));
  142. if (save_as)
  143. editor->save_resource_as(current_res);
  144. else
  145. editor->save_resource(current_res);
  146. }
  147. void InspectorDock::_unref_resource() const {
  148. uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
  149. Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
  150. ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
  151. RES current_res = RES(Object::cast_to<Resource>(current_obj));
  152. current_res->set_path("");
  153. editor->edit_current();
  154. }
  155. void InspectorDock::_copy_resource() const {
  156. uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
  157. Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
  158. ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
  159. RES current_res = RES(Object::cast_to<Resource>(current_obj));
  160. EditorSettings::get_singleton()->set_resource_clipboard(current_res);
  161. }
  162. void InspectorDock::_paste_resource() const {
  163. RES r = EditorSettings::get_singleton()->get_resource_clipboard();
  164. if (r.is_valid()) {
  165. editor->push_item(EditorSettings::get_singleton()->get_resource_clipboard().ptr(), String());
  166. }
  167. }
  168. void InspectorDock::_prepare_history() {
  169. EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
  170. int history_to = MAX(0, editor_history->get_history_len() - 25);
  171. history_menu->get_popup()->clear();
  172. Ref<Texture> base_icon = get_icon("Object", "EditorIcons");
  173. Set<ObjectID> already;
  174. for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) {
  175. ObjectID id = editor_history->get_history_obj(i);
  176. Object *obj = ObjectDB::get_instance(id);
  177. if (!obj || already.has(id)) {
  178. if (history_to > 0) {
  179. history_to--;
  180. }
  181. continue;
  182. }
  183. already.insert(id);
  184. Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj, "");
  185. if (icon.is_null()) {
  186. icon = base_icon;
  187. }
  188. String text;
  189. if (Object::cast_to<Resource>(obj)) {
  190. Resource *r = Object::cast_to<Resource>(obj);
  191. if (r->get_path().is_resource_file())
  192. text = r->get_path().get_file();
  193. else if (r->get_name() != String()) {
  194. text = r->get_name();
  195. } else {
  196. text = r->get_class();
  197. }
  198. } else if (Object::cast_to<Node>(obj)) {
  199. text = Object::cast_to<Node>(obj)->get_name();
  200. } else if (obj->is_class("ScriptEditorDebuggerInspectedObject")) {
  201. text = obj->call("get_title");
  202. } else {
  203. text = obj->get_class();
  204. }
  205. if (i == editor_history->get_history_pos() && current) {
  206. text = "[" + text + "]";
  207. }
  208. history_menu->get_popup()->add_icon_item(icon, text, i);
  209. }
  210. }
  211. void InspectorDock::_select_history(int p_idx) const {
  212. //push it to the top, it is not correct, but it's more useful
  213. ObjectID id = EditorNode::get_singleton()->get_editor_history()->get_history_obj(p_idx);
  214. Object *obj = ObjectDB::get_instance(id);
  215. if (!obj)
  216. return;
  217. editor->push_item(obj);
  218. }
  219. void InspectorDock::_resource_created() const {
  220. Variant c = new_resource_dialog->instance_selected();
  221. ERR_FAIL_COND(!c);
  222. Resource *r = Object::cast_to<Resource>(c);
  223. ERR_FAIL_COND(!r);
  224. editor->push_item(r);
  225. }
  226. void InspectorDock::_resource_selected(const RES &p_res, const String &p_property) const {
  227. if (p_res.is_null())
  228. return;
  229. RES r = p_res;
  230. editor->push_item(r.operator->(), p_property);
  231. }
  232. void InspectorDock::_edit_forward() {
  233. if (EditorNode::get_singleton()->get_editor_history()->next())
  234. editor->edit_current();
  235. }
  236. void InspectorDock::_edit_back() {
  237. EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
  238. if ((current && editor_history->previous()) || editor_history->get_path_size() == 1)
  239. editor->edit_current();
  240. }
  241. void InspectorDock::_menu_collapseall() {
  242. inspector->collapse_all_folding();
  243. }
  244. void InspectorDock::_menu_expandall() {
  245. inspector->expand_all_folding();
  246. }
  247. void InspectorDock::_property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance) {
  248. AnimationPlayerEditor::singleton->get_track_editor()->insert_value_key(p_keyed, p_value, p_advance);
  249. }
  250. void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) {
  251. Spatial *s = Object::cast_to<Spatial>(sp);
  252. if (!s)
  253. return;
  254. AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(s, p_sub, p_key);
  255. }
  256. void InspectorDock::_warning_pressed() {
  257. warning_dialog->popup_centered_minsize();
  258. }
  259. Container *InspectorDock::get_addon_area() {
  260. return this;
  261. }
  262. void InspectorDock::_notification(int p_what) {
  263. switch (p_what) {
  264. case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
  265. set_theme(editor->get_gui_base()->get_theme());
  266. resource_new_button->set_icon(get_icon("New", "EditorIcons"));
  267. resource_load_button->set_icon(get_icon("Load", "EditorIcons"));
  268. resource_save_button->set_icon(get_icon("Save", "EditorIcons"));
  269. backward_button->set_icon(get_icon("Back", "EditorIcons"));
  270. forward_button->set_icon(get_icon("Forward", "EditorIcons"));
  271. history_menu->set_icon(get_icon("History", "EditorIcons"));
  272. object_menu->set_icon(get_icon("Tools", "EditorIcons"));
  273. warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
  274. } break;
  275. }
  276. }
  277. void InspectorDock::_bind_methods() {
  278. ClassDB::bind_method("_menu_option", &InspectorDock::_menu_option);
  279. ClassDB::bind_method("update_keying", &InspectorDock::update_keying);
  280. ClassDB::bind_method("_property_keyed", &InspectorDock::_property_keyed);
  281. ClassDB::bind_method("_transform_keyed", &InspectorDock::_transform_keyed);
  282. ClassDB::bind_method("_new_resource", &InspectorDock::_new_resource);
  283. ClassDB::bind_method("_resource_file_selected", &InspectorDock::_resource_file_selected);
  284. ClassDB::bind_method("_open_resource_selector", &InspectorDock::_open_resource_selector);
  285. ClassDB::bind_method("_unref_resource", &InspectorDock::_unref_resource);
  286. ClassDB::bind_method("_paste_resource", &InspectorDock::_paste_resource);
  287. ClassDB::bind_method("_copy_resource", &InspectorDock::_copy_resource);
  288. ClassDB::bind_method("_select_history", &InspectorDock::_select_history);
  289. ClassDB::bind_method("_prepare_history", &InspectorDock::_prepare_history);
  290. ClassDB::bind_method("_resource_created", &InspectorDock::_resource_created);
  291. ClassDB::bind_method("_resource_selected", &InspectorDock::_resource_selected, DEFVAL(""));
  292. ClassDB::bind_method("_menu_collapseall", &InspectorDock::_menu_collapseall);
  293. ClassDB::bind_method("_menu_expandall", &InspectorDock::_menu_expandall);
  294. ClassDB::bind_method("_warning_pressed", &InspectorDock::_warning_pressed);
  295. ClassDB::bind_method("_edit_forward", &InspectorDock::_edit_forward);
  296. ClassDB::bind_method("_edit_back", &InspectorDock::_edit_back);
  297. ADD_SIGNAL(MethodInfo("request_help"));
  298. }
  299. void InspectorDock::edit_resource(const Ref<Resource> &p_resource) {
  300. _resource_selected(p_resource, "");
  301. }
  302. void InspectorDock::open_resource(const String &p_type) {
  303. _load_resource(p_type);
  304. }
  305. void InspectorDock::set_warning(const String &p_message) {
  306. warning->hide();
  307. if (p_message != String()) {
  308. warning->show();
  309. warning_dialog->set_text(p_message);
  310. }
  311. }
  312. void InspectorDock::clear() {
  313. }
  314. void InspectorDock::update(Object *p_object) {
  315. EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
  316. backward_button->set_disabled(editor_history->is_at_beginning());
  317. forward_button->set_disabled(editor_history->is_at_end());
  318. history_menu->set_disabled(true);
  319. if (editor_history->get_history_len() > 0) {
  320. history_menu->set_disabled(false);
  321. }
  322. editor_path->update_path();
  323. current = p_object;
  324. if (!p_object) {
  325. object_menu->set_disabled(true);
  326. warning->hide();
  327. search->set_editable(false);
  328. editor_path->set_disabled(true);
  329. editor_path->set_text("");
  330. editor_path->set_tooltip("");
  331. editor_path->set_icon(NULL);
  332. return;
  333. }
  334. bool is_resource = p_object->is_class("Resource");
  335. bool is_node = p_object->is_class("Node");
  336. object_menu->set_disabled(false);
  337. search->set_editable(true);
  338. editor_path->set_disabled(false);
  339. resource_save_button->set_disabled(!is_resource);
  340. PopupMenu *p = object_menu->get_popup();
  341. p->clear();
  342. p->add_shortcut(ED_SHORTCUT("property_editor/expand_all", TTR("Expand All Properties")), EXPAND_ALL);
  343. p->add_shortcut(ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All Properties")), COLLAPSE_ALL);
  344. p->add_separator();
  345. if (is_resource) {
  346. p->add_item(TTR("Save"), RESOURCE_SAVE);
  347. p->add_item(TTR("Save As..."), RESOURCE_SAVE_AS);
  348. p->add_separator();
  349. }
  350. p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Params")), OBJECT_COPY_PARAMS);
  351. p->add_shortcut(ED_SHORTCUT("property_editor/paste_params", TTR("Paste Params")), OBJECT_PASTE_PARAMS);
  352. p->add_separator();
  353. p->add_shortcut(ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource Clipboard")), RESOURCE_EDIT_CLIPBOARD);
  354. if (is_resource) {
  355. p->add_shortcut(ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY);
  356. p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Built-In")), RESOURCE_MAKE_BUILT_IN);
  357. }
  358. if (is_resource || is_node) {
  359. p->add_separator();
  360. p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES);
  361. p->add_separator();
  362. p->add_icon_shortcut(get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP);
  363. }
  364. List<MethodInfo> methods;
  365. p_object->get_method_list(&methods);
  366. if (!methods.empty()) {
  367. bool found = false;
  368. List<MethodInfo>::Element *I = methods.front();
  369. int i = 0;
  370. while (I) {
  371. if (I->get().flags & METHOD_FLAG_EDITOR) {
  372. if (!found) {
  373. p->add_separator();
  374. found = true;
  375. }
  376. p->add_item(I->get().name.capitalize(), OBJECT_METHOD_BASE + i);
  377. }
  378. i++;
  379. I = I->next();
  380. }
  381. }
  382. }
  383. void InspectorDock::go_back() {
  384. _edit_back();
  385. }
  386. void InspectorDock::update_keying() {
  387. bool valid = false;
  388. if (AnimationPlayerEditor::singleton->get_track_editor()->has_keying()) {
  389. EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
  390. if (editor_history->get_path_size() >= 1) {
  391. Object *obj = ObjectDB::get_instance(editor_history->get_path_object(0));
  392. if (Object::cast_to<Node>(obj)) {
  393. valid = true;
  394. }
  395. }
  396. }
  397. inspector->set_keying(valid);
  398. }
  399. InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
  400. set_name("Inspector");
  401. set_theme(p_editor->get_gui_base()->get_theme());
  402. editor = p_editor;
  403. editor_data = &p_editor_data;
  404. HBoxContainer *general_options_hb = memnew(HBoxContainer);
  405. add_child(general_options_hb);
  406. resource_new_button = memnew(ToolButton);
  407. resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it."));
  408. resource_new_button->set_icon(get_icon("New", "EditorIcons"));
  409. general_options_hb->add_child(resource_new_button);
  410. resource_new_button->connect("pressed", this, "_new_resource");
  411. resource_new_button->set_focus_mode(Control::FOCUS_NONE);
  412. resource_load_button = memnew(ToolButton);
  413. resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it."));
  414. resource_load_button->set_icon(get_icon("Load", "EditorIcons"));
  415. general_options_hb->add_child(resource_load_button);
  416. resource_load_button->connect("pressed", this, "_open_resource_selector");
  417. resource_load_button->set_focus_mode(Control::FOCUS_NONE);
  418. resource_save_button = memnew(MenuButton);
  419. resource_save_button->set_tooltip(TTR("Save the currently edited resource."));
  420. resource_save_button->set_icon(get_icon("Save", "EditorIcons"));
  421. general_options_hb->add_child(resource_save_button);
  422. resource_save_button->get_popup()->add_item(TTR("Save"), RESOURCE_SAVE);
  423. resource_save_button->get_popup()->add_item(TTR("Save As..."), RESOURCE_SAVE_AS);
  424. resource_save_button->get_popup()->connect("id_pressed", this, "_menu_option");
  425. resource_save_button->set_focus_mode(Control::FOCUS_NONE);
  426. resource_save_button->set_disabled(true);
  427. general_options_hb->add_spacer();
  428. backward_button = memnew(ToolButton);
  429. general_options_hb->add_child(backward_button);
  430. backward_button->set_icon(get_icon("Back", "EditorIcons"));
  431. backward_button->set_flat(true);
  432. backward_button->set_tooltip(TTR("Go to the previous edited object in history."));
  433. backward_button->set_disabled(true);
  434. backward_button->connect("pressed", this, "_edit_back");
  435. forward_button = memnew(ToolButton);
  436. general_options_hb->add_child(forward_button);
  437. forward_button->set_icon(get_icon("Forward", "EditorIcons"));
  438. forward_button->set_flat(true);
  439. forward_button->set_tooltip(TTR("Go to the next edited object in history."));
  440. forward_button->set_disabled(true);
  441. forward_button->connect("pressed", this, "_edit_forward");
  442. history_menu = memnew(MenuButton);
  443. history_menu->set_tooltip(TTR("History of recently edited objects."));
  444. history_menu->set_icon(get_icon("History", "EditorIcons"));
  445. general_options_hb->add_child(history_menu);
  446. history_menu->connect("about_to_show", this, "_prepare_history");
  447. history_menu->get_popup()->connect("id_pressed", this, "_select_history");
  448. HBoxContainer *node_info_hb = memnew(HBoxContainer);
  449. add_child(node_info_hb);
  450. editor_path = memnew(EditorPath(editor->get_editor_history()));
  451. editor_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  452. node_info_hb->add_child(editor_path);
  453. object_menu = memnew(MenuButton);
  454. object_menu->set_icon(get_icon("Tools", "EditorIcons"));
  455. node_info_hb->add_child(object_menu);
  456. object_menu->set_tooltip(TTR("Object properties."));
  457. object_menu->get_popup()->connect("id_pressed", this, "_menu_option");
  458. new_resource_dialog = memnew(CreateDialog);
  459. editor->get_gui_base()->add_child(new_resource_dialog);
  460. new_resource_dialog->set_base_type("Resource");
  461. new_resource_dialog->connect("create", this, "_resource_created");
  462. search = memnew(LineEdit);
  463. search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  464. search->set_placeholder(TTR("Filter properties"));
  465. search->set_right_icon(get_icon("Search", "EditorIcons"));
  466. search->set_clear_button_enabled(true);
  467. add_child(search);
  468. warning = memnew(Button);
  469. add_child(warning);
  470. warning->set_text(TTR("Changes may be lost!"));
  471. warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
  472. warning->set_clip_text(true);
  473. warning->hide();
  474. warning->connect("pressed", this, "_warning_pressed");
  475. warning_dialog = memnew(AcceptDialog);
  476. editor->get_gui_base()->add_child(warning_dialog);
  477. load_resource_dialog = memnew(EditorFileDialog);
  478. add_child(load_resource_dialog);
  479. load_resource_dialog->set_current_dir("res://");
  480. load_resource_dialog->connect("file_selected", this, "_resource_file_selected");
  481. inspector = memnew(EditorInspector);
  482. add_child(inspector);
  483. inspector->set_autoclear(true);
  484. inspector->set_show_categories(true);
  485. inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  486. inspector->set_use_doc_hints(true);
  487. inspector->set_hide_script(false);
  488. inspector->set_enable_capitalize_paths(bool(EDITOR_GET("interface/inspector/capitalize_properties")));
  489. inspector->set_use_folding(!bool(EDITOR_GET("interface/inspector/disable_folding")));
  490. inspector->register_text_enter(search);
  491. inspector->set_undo_redo(&editor_data->get_undo_redo());
  492. inspector->set_use_filter(true); // TODO: check me
  493. inspector->connect("resource_selected", this, "_resource_selected");
  494. inspector->connect("property_keyed", this, "_property_keyed");
  495. }
  496. InspectorDock::~InspectorDock() {
  497. }