inspector_dock.cpp 20 KB

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