editor_properties.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. /**************************************************************************/
  2. /* editor_properties.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. #ifndef EDITOR_PROPERTIES_H
  31. #define EDITOR_PROPERTIES_H
  32. #include "editor/editor_inspector.h"
  33. class CheckBox;
  34. class ColorPickerButton;
  35. class CreateDialog;
  36. class EditorFileDialog;
  37. class EditorLocaleDialog;
  38. class EditorResourcePicker;
  39. class EditorSpinSlider;
  40. class MenuButton;
  41. class PropertySelector;
  42. class SceneTreeDialog;
  43. class TextEdit;
  44. class TextureButton;
  45. class EditorPropertyNil : public EditorProperty {
  46. GDCLASS(EditorPropertyNil, EditorProperty);
  47. LineEdit *text = nullptr;
  48. public:
  49. virtual void update_property() override;
  50. EditorPropertyNil();
  51. };
  52. class EditorPropertyText : public EditorProperty {
  53. GDCLASS(EditorPropertyText, EditorProperty);
  54. LineEdit *text = nullptr;
  55. bool updating = false;
  56. bool string_name = false;
  57. void _text_changed(const String &p_string);
  58. void _text_submitted(const String &p_string);
  59. protected:
  60. virtual void _set_read_only(bool p_read_only) override;
  61. public:
  62. void set_string_name(bool p_enabled);
  63. virtual void update_property() override;
  64. void set_placeholder(const String &p_string);
  65. void set_secret(bool p_enabled);
  66. EditorPropertyText();
  67. };
  68. class EditorPropertyMultilineText : public EditorProperty {
  69. GDCLASS(EditorPropertyMultilineText, EditorProperty);
  70. TextEdit *text = nullptr;
  71. AcceptDialog *big_text_dialog = nullptr;
  72. TextEdit *big_text = nullptr;
  73. Button *open_big_text = nullptr;
  74. void _big_text_changed();
  75. void _text_changed();
  76. void _open_big_text();
  77. bool expression = false;
  78. protected:
  79. virtual void _set_read_only(bool p_read_only) override;
  80. void _notification(int p_what);
  81. public:
  82. virtual void update_property() override;
  83. EditorPropertyMultilineText(bool p_expression = false);
  84. };
  85. class EditorPropertyTextEnum : public EditorProperty {
  86. GDCLASS(EditorPropertyTextEnum, EditorProperty);
  87. HBoxContainer *default_layout = nullptr;
  88. HBoxContainer *edit_custom_layout = nullptr;
  89. OptionButton *option_button = nullptr;
  90. Button *edit_button = nullptr;
  91. LineEdit *custom_value_edit = nullptr;
  92. Button *accept_button = nullptr;
  93. Button *cancel_button = nullptr;
  94. Vector<String> options;
  95. bool string_name = false;
  96. bool loose_mode = false;
  97. void _emit_changed_value(const String &p_string);
  98. void _option_selected(int p_which);
  99. void _edit_custom_value();
  100. void _custom_value_submitted(const String &p_value);
  101. void _custom_value_accepted();
  102. void _custom_value_canceled();
  103. protected:
  104. virtual void _set_read_only(bool p_read_only) override;
  105. void _notification(int p_what);
  106. public:
  107. void setup(const Vector<String> &p_options, bool p_string_name = false, bool p_loose_mode = false);
  108. virtual void update_property() override;
  109. EditorPropertyTextEnum();
  110. };
  111. class EditorPropertyPath : public EditorProperty {
  112. GDCLASS(EditorPropertyPath, EditorProperty);
  113. Vector<String> extensions;
  114. bool folder = false;
  115. bool global = false;
  116. bool save_mode = false;
  117. EditorFileDialog *dialog = nullptr;
  118. LineEdit *path = nullptr;
  119. Button *path_edit = nullptr;
  120. String _get_path_text();
  121. void _path_selected(const String &p_path);
  122. void _path_pressed();
  123. void _path_focus_exited();
  124. void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  125. bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  126. protected:
  127. virtual void _set_read_only(bool p_read_only) override;
  128. void _notification(int p_what);
  129. public:
  130. void setup(const Vector<String> &p_extensions, bool p_folder, bool p_global);
  131. void set_save_mode();
  132. virtual void update_property() override;
  133. EditorPropertyPath();
  134. };
  135. class EditorPropertyLocale : public EditorProperty {
  136. GDCLASS(EditorPropertyLocale, EditorProperty);
  137. EditorLocaleDialog *dialog = nullptr;
  138. LineEdit *locale = nullptr;
  139. Button *locale_edit = nullptr;
  140. void _locale_selected(const String &p_locale);
  141. void _locale_pressed();
  142. void _locale_focus_exited();
  143. protected:
  144. void _notification(int p_what);
  145. public:
  146. void setup(const String &p_hit_string);
  147. virtual void update_property() override;
  148. EditorPropertyLocale();
  149. };
  150. class EditorPropertyClassName : public EditorProperty {
  151. GDCLASS(EditorPropertyClassName, EditorProperty);
  152. private:
  153. CreateDialog *dialog = nullptr;
  154. Button *property = nullptr;
  155. String selected_type;
  156. String base_type;
  157. void _property_selected();
  158. void _dialog_created();
  159. protected:
  160. virtual void _set_read_only(bool p_read_only) override;
  161. public:
  162. void setup(const String &p_base_type, const String &p_selected_type);
  163. virtual void update_property() override;
  164. EditorPropertyClassName();
  165. };
  166. class EditorPropertyCheck : public EditorProperty {
  167. GDCLASS(EditorPropertyCheck, EditorProperty);
  168. CheckBox *checkbox = nullptr;
  169. void _checkbox_pressed();
  170. protected:
  171. virtual void _set_read_only(bool p_read_only) override;
  172. public:
  173. virtual void update_property() override;
  174. EditorPropertyCheck();
  175. };
  176. class EditorPropertyEnum : public EditorProperty {
  177. GDCLASS(EditorPropertyEnum, EditorProperty);
  178. OptionButton *options = nullptr;
  179. void _option_selected(int p_which);
  180. protected:
  181. virtual void _set_read_only(bool p_read_only) override;
  182. public:
  183. void setup(const Vector<String> &p_options);
  184. virtual void update_property() override;
  185. void set_option_button_clip(bool p_enable);
  186. EditorPropertyEnum();
  187. };
  188. class EditorPropertyFlags : public EditorProperty {
  189. GDCLASS(EditorPropertyFlags, EditorProperty);
  190. VBoxContainer *vbox = nullptr;
  191. Vector<CheckBox *> flags;
  192. Vector<uint32_t> flag_values;
  193. void _flag_toggled(int p_index);
  194. protected:
  195. virtual void _set_read_only(bool p_read_only) override;
  196. public:
  197. void setup(const Vector<String> &p_options);
  198. virtual void update_property() override;
  199. EditorPropertyFlags();
  200. };
  201. ///////////////////// LAYERS /////////////////////////
  202. class EditorPropertyLayersGrid : public Control {
  203. GDCLASS(EditorPropertyLayersGrid, Control);
  204. private:
  205. Vector<Rect2> flag_rects;
  206. Rect2 expand_rect;
  207. bool expand_hovered = false;
  208. bool expanded = false;
  209. int expansion_rows = 0;
  210. uint32_t hovered_index = INT32_MAX; // Nothing is hovered.
  211. bool read_only = false;
  212. int renamed_layer_index = -1;
  213. PopupMenu *layer_rename = nullptr;
  214. ConfirmationDialog *rename_dialog = nullptr;
  215. LineEdit *rename_dialog_text = nullptr;
  216. void _rename_pressed(int p_menu);
  217. void _rename_operation_confirm();
  218. void _update_hovered(const Vector2 &p_position);
  219. void _on_hover_exit();
  220. void _update_flag(bool p_replace);
  221. Size2 get_grid_size() const;
  222. protected:
  223. void _notification(int p_what);
  224. static void _bind_methods();
  225. public:
  226. uint32_t value = 0;
  227. int layer_group_size = 0;
  228. uint32_t layer_count = 0;
  229. Vector<String> names;
  230. Vector<String> tooltips;
  231. void set_read_only(bool p_read_only);
  232. virtual Size2 get_minimum_size() const override;
  233. virtual String get_tooltip(const Point2 &p_pos) const override;
  234. void gui_input(const Ref<InputEvent> &p_ev) override;
  235. void set_flag(uint32_t p_flag);
  236. EditorPropertyLayersGrid();
  237. };
  238. class EditorPropertyLayers : public EditorProperty {
  239. GDCLASS(EditorPropertyLayers, EditorProperty);
  240. public:
  241. enum LayerType {
  242. LAYER_PHYSICS_2D,
  243. LAYER_RENDER_2D,
  244. LAYER_NAVIGATION_2D,
  245. LAYER_PHYSICS_3D,
  246. LAYER_RENDER_3D,
  247. LAYER_NAVIGATION_3D,
  248. LAYER_AVOIDANCE,
  249. };
  250. private:
  251. EditorPropertyLayersGrid *grid = nullptr;
  252. void _grid_changed(uint32_t p_grid);
  253. String basename;
  254. LayerType layer_type;
  255. PopupMenu *layers = nullptr;
  256. TextureButton *button = nullptr;
  257. void _button_pressed();
  258. void _menu_pressed(int p_menu);
  259. void _refresh_names();
  260. protected:
  261. void _notification(int p_what);
  262. virtual void _set_read_only(bool p_read_only) override;
  263. public:
  264. void setup(LayerType p_layer_type);
  265. void set_layer_name(int p_index, const String &p_name);
  266. String get_layer_name(int p_index) const;
  267. virtual void update_property() override;
  268. EditorPropertyLayers();
  269. };
  270. class EditorPropertyInteger : public EditorProperty {
  271. GDCLASS(EditorPropertyInteger, EditorProperty);
  272. EditorSpinSlider *spin = nullptr;
  273. void _value_changed(int64_t p_val);
  274. protected:
  275. virtual void _set_read_only(bool p_read_only) override;
  276. public:
  277. virtual void update_property() override;
  278. void setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_hide_slider, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix = String());
  279. EditorPropertyInteger();
  280. };
  281. class EditorPropertyObjectID : public EditorProperty {
  282. GDCLASS(EditorPropertyObjectID, EditorProperty);
  283. Button *edit = nullptr;
  284. String base_type;
  285. void _edit_pressed();
  286. protected:
  287. virtual void _set_read_only(bool p_read_only) override;
  288. public:
  289. virtual void update_property() override;
  290. void setup(const String &p_base_type);
  291. EditorPropertyObjectID();
  292. };
  293. class EditorPropertySignal : public EditorProperty {
  294. GDCLASS(EditorPropertySignal, EditorProperty);
  295. Button *edit = nullptr;
  296. String base_type;
  297. void _edit_pressed();
  298. public:
  299. virtual void update_property() override;
  300. EditorPropertySignal();
  301. };
  302. class EditorPropertyCallable : public EditorProperty {
  303. GDCLASS(EditorPropertyCallable, EditorProperty);
  304. Button *edit = nullptr;
  305. String base_type;
  306. public:
  307. virtual void update_property() override;
  308. EditorPropertyCallable();
  309. };
  310. class EditorPropertyFloat : public EditorProperty {
  311. GDCLASS(EditorPropertyFloat, EditorProperty);
  312. EditorSpinSlider *spin = nullptr;
  313. bool radians_as_degrees = false;
  314. void _value_changed(double p_val);
  315. protected:
  316. virtual void _set_read_only(bool p_read_only) override;
  317. public:
  318. virtual void update_property() override;
  319. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_radians_as_degrees = false);
  320. EditorPropertyFloat();
  321. };
  322. class EditorPropertyEasing : public EditorProperty {
  323. GDCLASS(EditorPropertyEasing, EditorProperty);
  324. Control *easing_draw = nullptr;
  325. PopupMenu *preset = nullptr;
  326. EditorSpinSlider *spin = nullptr;
  327. bool dragging = false;
  328. bool full = false;
  329. bool flip = false;
  330. bool positive_only = false;
  331. enum {
  332. EASING_ZERO,
  333. EASING_LINEAR,
  334. EASING_IN,
  335. EASING_OUT,
  336. EASING_IN_OUT,
  337. EASING_OUT_IN,
  338. EASING_MAX
  339. };
  340. void _drag_easing(const Ref<InputEvent> &p_ev);
  341. void _draw_easing();
  342. void _set_preset(int);
  343. void _setup_spin();
  344. void _spin_value_changed(double p_value);
  345. void _spin_focus_exited();
  346. void _notification(int p_what);
  347. protected:
  348. virtual void _set_read_only(bool p_read_only) override;
  349. public:
  350. virtual void update_property() override;
  351. void setup(bool p_positive_only, bool p_flip);
  352. EditorPropertyEasing();
  353. };
  354. class EditorPropertyRect2 : public EditorProperty {
  355. GDCLASS(EditorPropertyRect2, EditorProperty);
  356. EditorSpinSlider *spin[4];
  357. void _value_changed(double p_val, const String &p_name);
  358. protected:
  359. virtual void _set_read_only(bool p_read_only) override;
  360. void _notification(int p_what);
  361. public:
  362. virtual void update_property() override;
  363. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  364. EditorPropertyRect2(bool p_force_wide = false);
  365. };
  366. class EditorPropertyRect2i : public EditorProperty {
  367. GDCLASS(EditorPropertyRect2i, EditorProperty);
  368. EditorSpinSlider *spin[4];
  369. void _value_changed(double p_val, const String &p_name);
  370. protected:
  371. virtual void _set_read_only(bool p_read_only) override;
  372. void _notification(int p_what);
  373. public:
  374. virtual void update_property() override;
  375. void setup(int p_min, int p_max, const String &p_suffix = String());
  376. EditorPropertyRect2i(bool p_force_wide = false);
  377. };
  378. class EditorPropertyPlane : public EditorProperty {
  379. GDCLASS(EditorPropertyPlane, EditorProperty);
  380. EditorSpinSlider *spin[4];
  381. void _value_changed(double p_val, const String &p_name);
  382. protected:
  383. virtual void _set_read_only(bool p_read_only) override;
  384. void _notification(int p_what);
  385. public:
  386. virtual void update_property() override;
  387. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  388. EditorPropertyPlane(bool p_force_wide = false);
  389. };
  390. class EditorPropertyQuaternion : public EditorProperty {
  391. GDCLASS(EditorPropertyQuaternion, EditorProperty);
  392. BoxContainer *default_layout = nullptr;
  393. EditorSpinSlider *spin[4];
  394. Button *warning = nullptr;
  395. AcceptDialog *warning_dialog = nullptr;
  396. Label *euler_label = nullptr;
  397. VBoxContainer *edit_custom_bc = nullptr;
  398. EditorSpinSlider *euler[3];
  399. Button *edit_button = nullptr;
  400. Vector3 edit_euler;
  401. void _value_changed(double p_val, const String &p_name);
  402. void _edit_custom_value();
  403. void _custom_value_changed(double p_val);
  404. void _warning_pressed();
  405. bool is_grabbing_euler();
  406. protected:
  407. virtual void _set_read_only(bool p_read_only) override;
  408. void _notification(int p_what);
  409. public:
  410. virtual void update_property() override;
  411. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String(), bool p_hide_editor = false);
  412. EditorPropertyQuaternion();
  413. };
  414. class EditorPropertyAABB : public EditorProperty {
  415. GDCLASS(EditorPropertyAABB, EditorProperty);
  416. EditorSpinSlider *spin[6];
  417. void _value_changed(double p_val, const String &p_name);
  418. protected:
  419. virtual void _set_read_only(bool p_read_only) override;
  420. void _notification(int p_what);
  421. public:
  422. virtual void update_property() override;
  423. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  424. EditorPropertyAABB();
  425. };
  426. class EditorPropertyTransform2D : public EditorProperty {
  427. GDCLASS(EditorPropertyTransform2D, EditorProperty);
  428. EditorSpinSlider *spin[6];
  429. void _value_changed(double p_val, const String &p_name);
  430. protected:
  431. virtual void _set_read_only(bool p_read_only) override;
  432. void _notification(int p_what);
  433. public:
  434. virtual void update_property() override;
  435. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  436. EditorPropertyTransform2D(bool p_include_origin = true);
  437. };
  438. class EditorPropertyBasis : public EditorProperty {
  439. GDCLASS(EditorPropertyBasis, EditorProperty);
  440. EditorSpinSlider *spin[9];
  441. void _value_changed(double p_val, const String &p_name);
  442. protected:
  443. virtual void _set_read_only(bool p_read_only) override;
  444. void _notification(int p_what);
  445. public:
  446. virtual void update_property() override;
  447. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  448. EditorPropertyBasis();
  449. };
  450. class EditorPropertyTransform3D : public EditorProperty {
  451. GDCLASS(EditorPropertyTransform3D, EditorProperty);
  452. EditorSpinSlider *spin[12];
  453. void _value_changed(double p_val, const String &p_name);
  454. protected:
  455. virtual void _set_read_only(bool p_read_only) override;
  456. void _notification(int p_what);
  457. public:
  458. virtual void update_property() override;
  459. virtual void update_using_transform(Transform3D p_transform);
  460. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  461. EditorPropertyTransform3D();
  462. };
  463. class EditorPropertyProjection : public EditorProperty {
  464. GDCLASS(EditorPropertyProjection, EditorProperty);
  465. EditorSpinSlider *spin[16];
  466. void _value_changed(double p_val, const String &p_name);
  467. protected:
  468. virtual void _set_read_only(bool p_read_only) override;
  469. void _notification(int p_what);
  470. public:
  471. virtual void update_property() override;
  472. virtual void update_using_transform(Projection p_transform);
  473. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  474. EditorPropertyProjection();
  475. };
  476. class EditorPropertyColor : public EditorProperty {
  477. GDCLASS(EditorPropertyColor, EditorProperty);
  478. ColorPickerButton *picker = nullptr;
  479. void _color_changed(const Color &p_color);
  480. void _popup_closed();
  481. void _picker_opening();
  482. Color last_color;
  483. bool live_changes_enabled = true;
  484. bool was_checked = false;
  485. protected:
  486. virtual void _set_read_only(bool p_read_only) override;
  487. void _notification(int p_what);
  488. public:
  489. virtual void update_property() override;
  490. void setup(bool p_show_alpha);
  491. void set_live_changes_enabled(bool p_enabled);
  492. EditorPropertyColor();
  493. };
  494. class EditorPropertyNodePath : public EditorProperty {
  495. GDCLASS(EditorPropertyNodePath, EditorProperty);
  496. enum {
  497. ACTION_CLEAR,
  498. ACTION_COPY,
  499. ACTION_EDIT,
  500. ACTION_SELECT,
  501. };
  502. Button *assign = nullptr;
  503. MenuButton *menu = nullptr;
  504. LineEdit *edit = nullptr;
  505. SceneTreeDialog *scene_tree = nullptr;
  506. bool use_path_from_scene_root = false;
  507. bool editing_node = false;
  508. Vector<StringName> valid_types;
  509. void _node_selected(const NodePath &p_path, bool p_absolute = true);
  510. void _node_assign();
  511. Node *get_base_node();
  512. void _update_menu();
  513. void _menu_option(int p_idx);
  514. void _accept_text();
  515. void _text_submitted(const String &p_text);
  516. const NodePath _get_node_path() const;
  517. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  518. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  519. bool is_drop_valid(const Dictionary &p_drag_data) const;
  520. virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const override;
  521. protected:
  522. virtual void _set_read_only(bool p_read_only) override;
  523. void _notification(int p_what);
  524. public:
  525. virtual void update_property() override;
  526. void setup(const Vector<StringName> &p_valid_types, bool p_use_path_from_scene_root = true, bool p_editing_node = false);
  527. EditorPropertyNodePath();
  528. };
  529. class EditorPropertyRID : public EditorProperty {
  530. GDCLASS(EditorPropertyRID, EditorProperty);
  531. Label *label = nullptr;
  532. public:
  533. virtual void update_property() override;
  534. EditorPropertyRID();
  535. };
  536. class EditorPropertyResource : public EditorProperty {
  537. GDCLASS(EditorPropertyResource, EditorProperty);
  538. EditorResourcePicker *resource_picker = nullptr;
  539. SceneTreeDialog *scene_tree = nullptr;
  540. bool use_sub_inspector = false;
  541. EditorInspector *sub_inspector = nullptr;
  542. bool opened_editor = false;
  543. void _resource_selected(const Ref<Resource> &p_resource, bool p_inspect);
  544. void _resource_changed(const Ref<Resource> &p_resource);
  545. void _viewport_selected(const NodePath &p_path);
  546. void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance);
  547. void _sub_inspector_resource_selected(const Ref<Resource> &p_resource, const String &p_property);
  548. void _sub_inspector_object_id_selected(int p_id);
  549. void _open_editor_pressed();
  550. void _update_preferred_shader();
  551. bool _should_stop_editing() const;
  552. protected:
  553. virtual void _set_read_only(bool p_read_only) override;
  554. void _notification(int p_what);
  555. static void _bind_methods();
  556. public:
  557. virtual void update_property() override;
  558. void setup(Object *p_object, const String &p_path, const String &p_base_type);
  559. void collapse_all_folding() override;
  560. void expand_all_folding() override;
  561. void expand_revertable() override;
  562. void set_use_sub_inspector(bool p_enable);
  563. void fold_resource();
  564. virtual bool is_colored(ColorationMode p_mode) override;
  565. EditorPropertyResource();
  566. };
  567. ///////////////////////////////////////////////////
  568. /// \brief The EditorInspectorDefaultPlugin class
  569. ///
  570. class EditorInspectorDefaultPlugin : public EditorInspectorPlugin {
  571. GDCLASS(EditorInspectorDefaultPlugin, EditorInspectorPlugin);
  572. public:
  573. virtual bool can_handle(Object *p_object) override;
  574. virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
  575. static EditorProperty *get_editor_for_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false);
  576. };
  577. #endif // EDITOR_PROPERTIES_H