editor_properties.h 22 KB

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