editor_properties.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  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(const String &p_string);
  100. void _option_selected(int p_which);
  101. void _edit_custom_value();
  102. void _custom_value_submitted(const 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. 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 radians_as_degrees = false;
  329. void _value_changed(double p_val);
  330. protected:
  331. virtual void _set_read_only(bool p_read_only) override;
  332. static void _bind_methods();
  333. public:
  334. virtual void update_property() override;
  335. 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);
  336. EditorPropertyFloat();
  337. };
  338. class EditorPropertyEasing : public EditorProperty {
  339. GDCLASS(EditorPropertyEasing, EditorProperty);
  340. Control *easing_draw = nullptr;
  341. PopupMenu *preset = nullptr;
  342. EditorSpinSlider *spin = nullptr;
  343. bool dragging = false;
  344. bool full = false;
  345. bool flip = false;
  346. bool positive_only = false;
  347. enum {
  348. EASING_ZERO,
  349. EASING_LINEAR,
  350. EASING_IN,
  351. EASING_OUT,
  352. EASING_IN_OUT,
  353. EASING_OUT_IN,
  354. EASING_MAX
  355. };
  356. void _drag_easing(const Ref<InputEvent> &p_ev);
  357. void _draw_easing();
  358. void _set_preset(int);
  359. void _setup_spin();
  360. void _spin_value_changed(double p_value);
  361. void _spin_focus_exited();
  362. void _notification(int p_what);
  363. protected:
  364. virtual void _set_read_only(bool p_read_only) override;
  365. static void _bind_methods();
  366. public:
  367. virtual void update_property() override;
  368. void setup(bool p_positive_only, bool p_flip);
  369. EditorPropertyEasing();
  370. };
  371. class EditorPropertyRect2 : public EditorProperty {
  372. GDCLASS(EditorPropertyRect2, EditorProperty);
  373. EditorSpinSlider *spin[4];
  374. void _value_changed(double p_val, const String &p_name);
  375. protected:
  376. virtual void _set_read_only(bool p_read_only) override;
  377. void _notification(int p_what);
  378. static void _bind_methods();
  379. public:
  380. virtual void update_property() override;
  381. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  382. EditorPropertyRect2(bool p_force_wide = false);
  383. };
  384. class EditorPropertyRect2i : public EditorProperty {
  385. GDCLASS(EditorPropertyRect2i, EditorProperty);
  386. EditorSpinSlider *spin[4];
  387. void _value_changed(double p_val, const String &p_name);
  388. protected:
  389. virtual void _set_read_only(bool p_read_only) override;
  390. void _notification(int p_what);
  391. static void _bind_methods();
  392. public:
  393. virtual void update_property() override;
  394. void setup(int p_min, int p_max, const String &p_suffix = String());
  395. EditorPropertyRect2i(bool p_force_wide = false);
  396. };
  397. class EditorPropertyPlane : public EditorProperty {
  398. GDCLASS(EditorPropertyPlane, EditorProperty);
  399. EditorSpinSlider *spin[4];
  400. void _value_changed(double p_val, const String &p_name);
  401. protected:
  402. virtual void _set_read_only(bool p_read_only) override;
  403. void _notification(int p_what);
  404. static void _bind_methods();
  405. public:
  406. virtual void update_property() override;
  407. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  408. EditorPropertyPlane(bool p_force_wide = false);
  409. };
  410. class EditorPropertyQuaternion : public EditorProperty {
  411. GDCLASS(EditorPropertyQuaternion, EditorProperty);
  412. BoxContainer *default_layout = nullptr;
  413. EditorSpinSlider *spin[4];
  414. Button *warning = nullptr;
  415. AcceptDialog *warning_dialog = nullptr;
  416. Label *euler_label = nullptr;
  417. VBoxContainer *edit_custom_bc = nullptr;
  418. EditorSpinSlider *euler[3];
  419. Button *edit_button = nullptr;
  420. Vector3 edit_euler;
  421. void _value_changed(double p_val, const String &p_name);
  422. void _edit_custom_value();
  423. void _custom_value_changed(double p_val);
  424. void _warning_pressed();
  425. bool is_grabbing_euler();
  426. protected:
  427. virtual void _set_read_only(bool p_read_only) override;
  428. void _notification(int p_what);
  429. static void _bind_methods();
  430. public:
  431. virtual void update_property() override;
  432. 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);
  433. EditorPropertyQuaternion();
  434. };
  435. class EditorPropertyAABB : public EditorProperty {
  436. GDCLASS(EditorPropertyAABB, EditorProperty);
  437. EditorSpinSlider *spin[6];
  438. void _value_changed(double p_val, const String &p_name);
  439. protected:
  440. virtual void _set_read_only(bool p_read_only) override;
  441. void _notification(int p_what);
  442. static void _bind_methods();
  443. public:
  444. virtual void update_property() override;
  445. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  446. EditorPropertyAABB();
  447. };
  448. class EditorPropertyTransform2D : public EditorProperty {
  449. GDCLASS(EditorPropertyTransform2D, EditorProperty);
  450. EditorSpinSlider *spin[6];
  451. void _value_changed(double p_val, const String &p_name);
  452. protected:
  453. virtual void _set_read_only(bool p_read_only) override;
  454. void _notification(int p_what);
  455. static void _bind_methods();
  456. public:
  457. virtual void update_property() override;
  458. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  459. EditorPropertyTransform2D(bool p_include_origin = true);
  460. };
  461. class EditorPropertyBasis : public EditorProperty {
  462. GDCLASS(EditorPropertyBasis, EditorProperty);
  463. EditorSpinSlider *spin[9];
  464. void _value_changed(double p_val, const String &p_name);
  465. protected:
  466. virtual void _set_read_only(bool p_read_only) override;
  467. void _notification(int p_what);
  468. static void _bind_methods();
  469. public:
  470. virtual void update_property() override;
  471. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  472. EditorPropertyBasis();
  473. };
  474. class EditorPropertyTransform3D : public EditorProperty {
  475. GDCLASS(EditorPropertyTransform3D, EditorProperty);
  476. EditorSpinSlider *spin[12];
  477. void _value_changed(double p_val, const String &p_name);
  478. protected:
  479. virtual void _set_read_only(bool p_read_only) override;
  480. void _notification(int p_what);
  481. static void _bind_methods();
  482. public:
  483. virtual void update_property() override;
  484. virtual void update_using_transform(Transform3D p_transform);
  485. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  486. EditorPropertyTransform3D();
  487. };
  488. class EditorPropertyProjection : public EditorProperty {
  489. GDCLASS(EditorPropertyProjection, EditorProperty);
  490. EditorSpinSlider *spin[16];
  491. void _value_changed(double p_val, const String &p_name);
  492. protected:
  493. virtual void _set_read_only(bool p_read_only) override;
  494. void _notification(int p_what);
  495. static void _bind_methods();
  496. public:
  497. virtual void update_property() override;
  498. virtual void update_using_transform(Projection p_transform);
  499. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  500. EditorPropertyProjection();
  501. };
  502. class EditorPropertyColor : public EditorProperty {
  503. GDCLASS(EditorPropertyColor, EditorProperty);
  504. ColorPickerButton *picker = nullptr;
  505. void _color_changed(const Color &p_color);
  506. void _popup_closed();
  507. void _picker_opening();
  508. Color last_color;
  509. bool live_changes_enabled = true;
  510. protected:
  511. virtual void _set_read_only(bool p_read_only) override;
  512. void _notification(int p_what);
  513. public:
  514. virtual void update_property() override;
  515. void setup(bool p_show_alpha);
  516. void set_live_changes_enabled(bool p_enabled);
  517. EditorPropertyColor();
  518. };
  519. class EditorPropertyNodePath : public EditorProperty {
  520. GDCLASS(EditorPropertyNodePath, EditorProperty);
  521. enum {
  522. ACTION_CLEAR,
  523. ACTION_COPY,
  524. ACTION_EDIT,
  525. ACTION_SELECT,
  526. };
  527. Button *assign = nullptr;
  528. MenuButton *menu = nullptr;
  529. LineEdit *edit = nullptr;
  530. SceneTreeDialog *scene_tree = nullptr;
  531. NodePath base_hint;
  532. bool use_path_from_scene_root = false;
  533. bool editing_node = false;
  534. Vector<StringName> valid_types;
  535. void _node_selected(const NodePath &p_path);
  536. void _node_assign();
  537. Node *get_base_node();
  538. void _update_menu();
  539. void _menu_option(int p_idx);
  540. void _accept_text();
  541. void _text_submitted(const String &p_text);
  542. const NodePath _get_node_path() const;
  543. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  544. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  545. bool is_drop_valid(const Dictionary &p_drag_data) const;
  546. virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const override;
  547. protected:
  548. virtual void _set_read_only(bool p_read_only) override;
  549. void _notification(int p_what);
  550. public:
  551. virtual void update_property() override;
  552. void setup(const NodePath &p_base_hint, const 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. bool opened_editor = false;
  569. void _resource_selected(const Ref<Resource> &p_resource, bool p_inspect);
  570. void _resource_changed(const Ref<Resource> &p_resource);
  571. void _viewport_selected(const NodePath &p_path);
  572. void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance);
  573. void _sub_inspector_resource_selected(const Ref<Resource> &p_resource, const String &p_property);
  574. void _sub_inspector_object_id_selected(int p_id);
  575. void _open_editor_pressed();
  576. void _update_preferred_shader();
  577. protected:
  578. virtual void _set_read_only(bool p_read_only) override;
  579. void _notification(int p_what);
  580. public:
  581. virtual void update_property() override;
  582. void setup(Object *p_object, const String &p_path, const String &p_base_type);
  583. void collapse_all_folding() override;
  584. void expand_all_folding() override;
  585. void expand_revertable() override;
  586. void set_use_sub_inspector(bool p_enable);
  587. void fold_resource();
  588. virtual bool is_colored(ColorationMode p_mode) override;
  589. EditorPropertyResource();
  590. };
  591. ///////////////////////////////////////////////////
  592. /// \brief The EditorInspectorDefaultPlugin class
  593. ///
  594. class EditorInspectorDefaultPlugin : public EditorInspectorPlugin {
  595. GDCLASS(EditorInspectorDefaultPlugin, EditorInspectorPlugin);
  596. public:
  597. virtual bool can_handle(Object *p_object) override;
  598. 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;
  599. 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);
  600. };
  601. #endif // EDITOR_PROPERTIES_H