editor_properties.h 22 KB

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