inspector_dock.cpp 21 KB

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