2
0

editor_properties.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. /*************************************************************************/
  2. /* editor_properties.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef EDITOR_PROPERTIES_H
  31. #define EDITOR_PROPERTIES_H
  32. #include "editor/create_dialog.h"
  33. #include "editor/editor_inspector.h"
  34. #include "editor/editor_locale_dialog.h"
  35. #include "editor/editor_resource_picker.h"
  36. #include "editor/editor_spin_slider.h"
  37. #include "editor/property_selector.h"
  38. #include "editor/scene_tree_editor.h"
  39. #include "scene/gui/color_picker.h"
  40. #include "scene/gui/line_edit.h"
  41. class EditorPropertyNil : public EditorProperty {
  42. GDCLASS(EditorPropertyNil, EditorProperty);
  43. LineEdit *text = nullptr;
  44. public:
  45. virtual void update_property() override;
  46. EditorPropertyNil();
  47. };
  48. class EditorPropertyText : public EditorProperty {
  49. GDCLASS(EditorPropertyText, EditorProperty);
  50. LineEdit *text = nullptr;
  51. bool updating = false;
  52. bool string_name = false;
  53. void _text_changed(const String &p_string);
  54. void _text_submitted(const String &p_string);
  55. protected:
  56. virtual void _set_read_only(bool p_read_only) override;
  57. static void _bind_methods();
  58. public:
  59. void set_string_name(bool p_enabled);
  60. virtual void update_property() override;
  61. void set_placeholder(const String &p_string);
  62. EditorPropertyText();
  63. };
  64. class EditorPropertyMultilineText : public EditorProperty {
  65. GDCLASS(EditorPropertyMultilineText, EditorProperty);
  66. TextEdit *text = nullptr;
  67. AcceptDialog *big_text_dialog = nullptr;
  68. TextEdit *big_text = nullptr;
  69. Button *open_big_text = nullptr;
  70. void _big_text_changed();
  71. void _text_changed();
  72. void _open_big_text();
  73. protected:
  74. virtual void _set_read_only(bool p_read_only) override;
  75. void _notification(int p_what);
  76. static void _bind_methods();
  77. public:
  78. virtual void update_property() override;
  79. EditorPropertyMultilineText();
  80. };
  81. class EditorPropertyTextEnum : public EditorProperty {
  82. GDCLASS(EditorPropertyTextEnum, EditorProperty);
  83. HBoxContainer *default_layout = nullptr;
  84. HBoxContainer *edit_custom_layout = nullptr;
  85. OptionButton *option_button = nullptr;
  86. Button *edit_button = nullptr;
  87. LineEdit *custom_value_edit = nullptr;
  88. Button *accept_button = nullptr;
  89. Button *cancel_button = nullptr;
  90. Vector<String> options;
  91. bool string_name = false;
  92. bool loose_mode = false;
  93. void _emit_changed_value(String p_string);
  94. void _option_selected(int p_which);
  95. void _edit_custom_value();
  96. void _custom_value_submitted(String p_value);
  97. void _custom_value_accepted();
  98. void _custom_value_cancelled();
  99. protected:
  100. virtual void _set_read_only(bool p_read_only) override;
  101. static void _bind_methods();
  102. void _notification(int p_what);
  103. public:
  104. void setup(const Vector<String> &p_options, bool p_string_name = false, bool p_loose_mode = false);
  105. virtual void update_property() override;
  106. EditorPropertyTextEnum();
  107. };
  108. class EditorPropertyPath : public EditorProperty {
  109. GDCLASS(EditorPropertyPath, EditorProperty);
  110. Vector<String> extensions;
  111. bool folder = false;
  112. bool global = false;
  113. bool save_mode = false;
  114. EditorFileDialog *dialog = nullptr;
  115. LineEdit *path = nullptr;
  116. Button *path_edit = nullptr;
  117. void _path_selected(const String &p_path);
  118. void _path_pressed();
  119. void _path_focus_exited();
  120. protected:
  121. virtual void _set_read_only(bool p_read_only) override;
  122. static void _bind_methods();
  123. void _notification(int p_what);
  124. public:
  125. void setup(const Vector<String> &p_extensions, bool p_folder, bool p_global);
  126. void set_save_mode();
  127. virtual void update_property() override;
  128. EditorPropertyPath();
  129. };
  130. class EditorPropertyLocale : public EditorProperty {
  131. GDCLASS(EditorPropertyLocale, EditorProperty);
  132. EditorLocaleDialog *dialog = nullptr;
  133. LineEdit *locale = nullptr;
  134. Button *locale_edit = nullptr;
  135. void _locale_selected(const String &p_locale);
  136. void _locale_pressed();
  137. void _locale_focus_exited();
  138. protected:
  139. static void _bind_methods();
  140. void _notification(int p_what);
  141. public:
  142. void setup(const String &p_hit_string);
  143. virtual void update_property() override;
  144. EditorPropertyLocale();
  145. };
  146. class EditorPropertyClassName : public EditorProperty {
  147. GDCLASS(EditorPropertyClassName, EditorProperty);
  148. private:
  149. CreateDialog *dialog = nullptr;
  150. Button *property = nullptr;
  151. String selected_type;
  152. String base_type;
  153. void _property_selected();
  154. void _dialog_created();
  155. protected:
  156. virtual void _set_read_only(bool p_read_only) override;
  157. static void _bind_methods();
  158. public:
  159. void setup(const String &p_base_type, const String &p_selected_type);
  160. virtual void update_property() override;
  161. EditorPropertyClassName();
  162. };
  163. class EditorPropertyMember : public EditorProperty {
  164. GDCLASS(EditorPropertyMember, EditorProperty);
  165. public:
  166. enum Type {
  167. MEMBER_METHOD_OF_VARIANT_TYPE, ///< a method of a type
  168. MEMBER_METHOD_OF_BASE_TYPE, ///< a method of a base type
  169. MEMBER_METHOD_OF_INSTANCE, ///< a method of an instance
  170. MEMBER_METHOD_OF_SCRIPT, ///< a method of a script & base
  171. MEMBER_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
  172. MEMBER_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
  173. MEMBER_PROPERTY_OF_INSTANCE, ///< a property of an instance
  174. MEMBER_PROPERTY_OF_SCRIPT, ///< a property of a script & base
  175. };
  176. private:
  177. Type hint;
  178. PropertySelector *selector = nullptr;
  179. Button *property = nullptr;
  180. String hint_text;
  181. void _property_selected(const String &p_selected);
  182. void _property_select();
  183. protected:
  184. virtual void _set_read_only(bool p_read_only) override;
  185. static void _bind_methods();
  186. public:
  187. void setup(Type p_hint, const String &p_hint_text);
  188. virtual void update_property() override;
  189. EditorPropertyMember();
  190. };
  191. class EditorPropertyCheck : public EditorProperty {
  192. GDCLASS(EditorPropertyCheck, EditorProperty);
  193. CheckBox *checkbox = nullptr;
  194. void _checkbox_pressed();
  195. protected:
  196. virtual void _set_read_only(bool p_read_only) override;
  197. static void _bind_methods();
  198. public:
  199. virtual void update_property() override;
  200. EditorPropertyCheck();
  201. };
  202. class EditorPropertyEnum : public EditorProperty {
  203. GDCLASS(EditorPropertyEnum, EditorProperty);
  204. OptionButton *options = nullptr;
  205. void _option_selected(int p_which);
  206. protected:
  207. virtual void _set_read_only(bool p_read_only) override;
  208. static void _bind_methods();
  209. public:
  210. void setup(const Vector<String> &p_options);
  211. virtual void update_property() override;
  212. void set_option_button_clip(bool p_enable);
  213. EditorPropertyEnum();
  214. };
  215. class EditorPropertyFlags : public EditorProperty {
  216. GDCLASS(EditorPropertyFlags, EditorProperty);
  217. VBoxContainer *vbox = nullptr;
  218. Vector<CheckBox *> flags;
  219. Vector<int> flag_indices;
  220. void _flag_toggled();
  221. protected:
  222. virtual void _set_read_only(bool p_read_only) override;
  223. static void _bind_methods();
  224. public:
  225. void setup(const Vector<String> &p_options);
  226. virtual void update_property() override;
  227. EditorPropertyFlags();
  228. };
  229. ///////////////////// LAYERS /////////////////////////
  230. class EditorPropertyLayersGrid : public Control {
  231. GDCLASS(EditorPropertyLayersGrid, Control);
  232. private:
  233. Vector<Rect2> flag_rects;
  234. Rect2 expand_rect;
  235. bool expand_hovered = false;
  236. bool expanded = false;
  237. int expansion_rows = 0;
  238. int hovered_index = -1;
  239. bool read_only = false;
  240. int renamed_layer_index = -1;
  241. PopupMenu *layer_rename = nullptr;
  242. ConfirmationDialog *rename_dialog = nullptr;
  243. LineEdit *rename_dialog_text = nullptr;
  244. void _rename_pressed(int p_menu);
  245. void _rename_operation_confirm();
  246. Size2 get_grid_size() const;
  247. protected:
  248. void _notification(int p_what);
  249. static void _bind_methods();
  250. public:
  251. uint32_t value = 0;
  252. int layer_group_size = 0;
  253. int layer_count = 0;
  254. Vector<String> names;
  255. Vector<String> tooltips;
  256. void set_read_only(bool p_read_only);
  257. virtual Size2 get_minimum_size() const override;
  258. virtual String get_tooltip(const Point2 &p_pos) const override;
  259. void gui_input(const Ref<InputEvent> &p_ev) override;
  260. void set_flag(uint32_t p_flag);
  261. EditorPropertyLayersGrid();
  262. };
  263. class EditorPropertyLayers : public EditorProperty {
  264. GDCLASS(EditorPropertyLayers, EditorProperty);
  265. public:
  266. enum LayerType {
  267. LAYER_PHYSICS_2D,
  268. LAYER_RENDER_2D,
  269. LAYER_NAVIGATION_2D,
  270. LAYER_PHYSICS_3D,
  271. LAYER_RENDER_3D,
  272. LAYER_NAVIGATION_3D,
  273. };
  274. private:
  275. EditorPropertyLayersGrid *grid = nullptr;
  276. void _grid_changed(uint32_t p_grid);
  277. String basename;
  278. LayerType layer_type;
  279. PopupMenu *layers = nullptr;
  280. Button *button = nullptr;
  281. void _button_pressed();
  282. void _menu_pressed(int p_menu);
  283. void _refresh_names();
  284. protected:
  285. virtual void _set_read_only(bool p_read_only) override;
  286. static void _bind_methods();
  287. public:
  288. void setup(LayerType p_layer_type);
  289. void set_layer_name(int p_index, const String &p_name);
  290. virtual void update_property() override;
  291. EditorPropertyLayers();
  292. };
  293. class EditorPropertyInteger : public EditorProperty {
  294. GDCLASS(EditorPropertyInteger, EditorProperty);
  295. EditorSpinSlider *spin = nullptr;
  296. bool setting = false;
  297. void _value_changed(int64_t p_val);
  298. protected:
  299. virtual void _set_read_only(bool p_read_only) override;
  300. static void _bind_methods();
  301. public:
  302. virtual void update_property() override;
  303. void setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_allow_greater, bool p_allow_lesser);
  304. EditorPropertyInteger();
  305. };
  306. class EditorPropertyObjectID : public EditorProperty {
  307. GDCLASS(EditorPropertyObjectID, EditorProperty);
  308. Button *edit = nullptr;
  309. String base_type;
  310. void _edit_pressed();
  311. protected:
  312. virtual void _set_read_only(bool p_read_only) override;
  313. static void _bind_methods();
  314. public:
  315. virtual void update_property() override;
  316. void setup(const String &p_base_type);
  317. EditorPropertyObjectID();
  318. };
  319. class EditorPropertyFloat : public EditorProperty {
  320. GDCLASS(EditorPropertyFloat, EditorProperty);
  321. EditorSpinSlider *spin = nullptr;
  322. bool setting = false;
  323. bool angle_in_radians = false;
  324. void _value_changed(double p_val);
  325. protected:
  326. virtual void _set_read_only(bool p_read_only) override;
  327. static void _bind_methods();
  328. public:
  329. virtual void update_property() override;
  330. void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_angle_in_radians = false);
  331. EditorPropertyFloat();
  332. };
  333. class EditorPropertyEasing : public EditorProperty {
  334. GDCLASS(EditorPropertyEasing, EditorProperty);
  335. Control *easing_draw = nullptr;
  336. PopupMenu *preset = nullptr;
  337. EditorSpinSlider *spin = nullptr;
  338. bool setting = false;
  339. bool dragging = false;
  340. bool full = false;
  341. bool flip = false;
  342. enum {
  343. EASING_ZERO,
  344. EASING_LINEAR,
  345. EASING_IN,
  346. EASING_OUT,
  347. EASING_IN_OUT,
  348. EASING_OUT_IN,
  349. EASING_MAX
  350. };
  351. void _drag_easing(const Ref<InputEvent> &p_ev);
  352. void _draw_easing();
  353. void _set_preset(int);
  354. void _setup_spin();
  355. void _spin_value_changed(double p_value);
  356. void _spin_focus_exited();
  357. void _notification(int p_what);
  358. protected:
  359. virtual void _set_read_only(bool p_read_only) override;
  360. static void _bind_methods();
  361. public:
  362. virtual void update_property() override;
  363. void setup(bool p_full, bool p_flip);
  364. EditorPropertyEasing();
  365. };
  366. class EditorPropertyVector2 : public EditorProperty {
  367. GDCLASS(EditorPropertyVector2, EditorProperty);
  368. EditorSpinSlider *spin[2];
  369. bool setting = false;
  370. void _value_changed(double p_val, const String &p_name);
  371. protected:
  372. virtual void _set_read_only(bool p_read_only) override;
  373. void _notification(int p_what);
  374. static void _bind_methods();
  375. public:
  376. virtual void update_property() override;
  377. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  378. EditorPropertyVector2(bool p_force_wide = false);
  379. };
  380. class EditorPropertyRect2 : public EditorProperty {
  381. GDCLASS(EditorPropertyRect2, EditorProperty);
  382. EditorSpinSlider *spin[4];
  383. bool setting = false;
  384. void _value_changed(double p_val, const String &p_name);
  385. protected:
  386. virtual void _set_read_only(bool p_read_only) override;
  387. void _notification(int p_what);
  388. static void _bind_methods();
  389. public:
  390. virtual void update_property() override;
  391. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  392. EditorPropertyRect2(bool p_force_wide = false);
  393. };
  394. class EditorPropertyVector3 : public EditorProperty {
  395. GDCLASS(EditorPropertyVector3, EditorProperty);
  396. EditorSpinSlider *spin[3];
  397. bool setting = false;
  398. bool angle_in_radians = false;
  399. void _value_changed(double p_val, const String &p_name);
  400. protected:
  401. virtual void _set_read_only(bool p_read_only) override;
  402. void _notification(int p_what);
  403. static void _bind_methods();
  404. public:
  405. virtual void update_property() override;
  406. virtual void update_using_vector(Vector3 p_vector);
  407. virtual Vector3 get_vector();
  408. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String(), bool p_angle_in_radians = false);
  409. EditorPropertyVector3(bool p_force_wide = false);
  410. };
  411. class EditorPropertyVector2i : public EditorProperty {
  412. GDCLASS(EditorPropertyVector2i, EditorProperty);
  413. EditorSpinSlider *spin[2];
  414. bool setting = false;
  415. void _value_changed(double p_val, const String &p_name);
  416. protected:
  417. virtual void _set_read_only(bool p_read_only) override;
  418. void _notification(int p_what);
  419. static void _bind_methods();
  420. public:
  421. virtual void update_property() override;
  422. void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String());
  423. EditorPropertyVector2i(bool p_force_wide = false);
  424. };
  425. class EditorPropertyRect2i : public EditorProperty {
  426. GDCLASS(EditorPropertyRect2i, EditorProperty);
  427. EditorSpinSlider *spin[4];
  428. bool setting = false;
  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. static void _bind_methods();
  434. public:
  435. virtual void update_property() override;
  436. void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String());
  437. EditorPropertyRect2i(bool p_force_wide = false);
  438. };
  439. class EditorPropertyVector3i : public EditorProperty {
  440. GDCLASS(EditorPropertyVector3i, EditorProperty);
  441. EditorSpinSlider *spin[3];
  442. bool setting = false;
  443. void _value_changed(double p_val, const String &p_name);
  444. protected:
  445. virtual void _set_read_only(bool p_read_only) override;
  446. void _notification(int p_what);
  447. static void _bind_methods();
  448. public:
  449. virtual void update_property() override;
  450. void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String());
  451. EditorPropertyVector3i(bool p_force_wide = false);
  452. };
  453. class EditorPropertyPlane : public EditorProperty {
  454. GDCLASS(EditorPropertyPlane, EditorProperty);
  455. EditorSpinSlider *spin[4];
  456. bool setting = false;
  457. void _value_changed(double p_val, const String &p_name);
  458. protected:
  459. virtual void _set_read_only(bool p_read_only) override;
  460. void _notification(int p_what);
  461. static void _bind_methods();
  462. public:
  463. virtual void update_property() override;
  464. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  465. EditorPropertyPlane(bool p_force_wide = false);
  466. };
  467. class EditorPropertyQuaternion : public EditorProperty {
  468. GDCLASS(EditorPropertyQuaternion, EditorProperty);
  469. EditorSpinSlider *spin[4];
  470. bool setting = false;
  471. void _value_changed(double p_val, const String &p_name);
  472. protected:
  473. virtual void _set_read_only(bool p_read_only) override;
  474. void _notification(int p_what);
  475. static void _bind_methods();
  476. public:
  477. virtual void update_property() override;
  478. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  479. EditorPropertyQuaternion();
  480. };
  481. class EditorPropertyAABB : public EditorProperty {
  482. GDCLASS(EditorPropertyAABB, EditorProperty);
  483. EditorSpinSlider *spin[6];
  484. bool setting = false;
  485. void _value_changed(double p_val, const String &p_name);
  486. protected:
  487. virtual void _set_read_only(bool p_read_only) override;
  488. void _notification(int p_what);
  489. static void _bind_methods();
  490. public:
  491. virtual void update_property() override;
  492. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  493. EditorPropertyAABB();
  494. };
  495. class EditorPropertyTransform2D : public EditorProperty {
  496. GDCLASS(EditorPropertyTransform2D, EditorProperty);
  497. EditorSpinSlider *spin[6];
  498. bool setting = false;
  499. void _value_changed(double p_val, const String &p_name);
  500. protected:
  501. virtual void _set_read_only(bool p_read_only) override;
  502. void _notification(int p_what);
  503. static void _bind_methods();
  504. public:
  505. virtual void update_property() override;
  506. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  507. EditorPropertyTransform2D(bool p_include_origin = true);
  508. };
  509. class EditorPropertyBasis : public EditorProperty {
  510. GDCLASS(EditorPropertyBasis, EditorProperty);
  511. EditorSpinSlider *spin[9];
  512. bool setting = false;
  513. void _value_changed(double p_val, const String &p_name);
  514. protected:
  515. virtual void _set_read_only(bool p_read_only) override;
  516. void _notification(int p_what);
  517. static void _bind_methods();
  518. public:
  519. virtual void update_property() override;
  520. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  521. EditorPropertyBasis();
  522. };
  523. class EditorPropertyTransform3D : public EditorProperty {
  524. GDCLASS(EditorPropertyTransform3D, EditorProperty);
  525. EditorSpinSlider *spin[12];
  526. bool setting = false;
  527. void _value_changed(double p_val, const String &p_name);
  528. protected:
  529. virtual void _set_read_only(bool p_read_only) override;
  530. void _notification(int p_what);
  531. static void _bind_methods();
  532. public:
  533. virtual void update_property() override;
  534. virtual void update_using_transform(Transform3D p_transform);
  535. void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
  536. EditorPropertyTransform3D();
  537. };
  538. class EditorPropertyColor : public EditorProperty {
  539. GDCLASS(EditorPropertyColor, EditorProperty);
  540. ColorPickerButton *picker = nullptr;
  541. void _color_changed(const Color &p_color);
  542. void _popup_closed();
  543. void _picker_created();
  544. void _picker_opening();
  545. Color last_color;
  546. protected:
  547. virtual void _set_read_only(bool p_read_only) override;
  548. static void _bind_methods();
  549. public:
  550. virtual void update_property() override;
  551. void setup(bool p_show_alpha);
  552. EditorPropertyColor();
  553. };
  554. class EditorPropertyNodePath : public EditorProperty {
  555. GDCLASS(EditorPropertyNodePath, EditorProperty);
  556. Button *assign = nullptr;
  557. Button *clear = nullptr;
  558. SceneTreeDialog *scene_tree = nullptr;
  559. NodePath base_hint;
  560. bool use_path_from_scene_root = false;
  561. Vector<StringName> valid_types;
  562. void _node_selected(const NodePath &p_path);
  563. void _node_assign();
  564. void _node_clear();
  565. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  566. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  567. bool is_drop_valid(const Dictionary &p_drag_data) const;
  568. protected:
  569. virtual void _set_read_only(bool p_read_only) override;
  570. static void _bind_methods();
  571. void _notification(int p_what);
  572. public:
  573. virtual void update_property() override;
  574. void setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root = true);
  575. EditorPropertyNodePath();
  576. };
  577. class EditorPropertyRID : public EditorProperty {
  578. GDCLASS(EditorPropertyRID, EditorProperty);
  579. Label *label = nullptr;
  580. public:
  581. virtual void update_property() override;
  582. EditorPropertyRID();
  583. };
  584. class EditorPropertyResource : public EditorProperty {
  585. GDCLASS(EditorPropertyResource, EditorProperty);
  586. EditorResourcePicker *resource_picker = nullptr;
  587. SceneTreeDialog *scene_tree = nullptr;
  588. bool use_sub_inspector = false;
  589. EditorInspector *sub_inspector = nullptr;
  590. VBoxContainer *sub_inspector_vbox = nullptr;
  591. bool updating_theme = false;
  592. bool opened_editor = false;
  593. void _resource_selected(const Ref<Resource> &p_resource, bool p_edit);
  594. void _resource_changed(const Ref<Resource> &p_resource);
  595. void _viewport_selected(const NodePath &p_path);
  596. void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance);
  597. void _sub_inspector_resource_selected(const Ref<Resource> &p_resource, const String &p_property);
  598. void _sub_inspector_object_id_selected(int p_id);
  599. void _open_editor_pressed();
  600. void _fold_other_editors(Object *p_self);
  601. void _update_property_bg();
  602. void _update_preferred_shader();
  603. protected:
  604. virtual void _set_read_only(bool p_read_only) override;
  605. static void _bind_methods();
  606. void _notification(int p_what);
  607. public:
  608. virtual void update_property() override;
  609. void setup(Object *p_object, const String &p_path, const String &p_base_type);
  610. void collapse_all_folding() override;
  611. void expand_all_folding() override;
  612. void set_use_sub_inspector(bool p_enable);
  613. EditorPropertyResource();
  614. };
  615. ///////////////////////////////////////////////////
  616. /// \brief The EditorInspectorDefaultPlugin class
  617. ///
  618. class EditorInspectorDefaultPlugin : public EditorInspectorPlugin {
  619. GDCLASS(EditorInspectorDefaultPlugin, EditorInspectorPlugin);
  620. public:
  621. virtual bool can_handle(Object *p_object) override;
  622. 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 uint32_t p_usage, const bool p_wide = false) override;
  623. 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 uint32_t p_usage, const bool p_wide = false);
  624. };
  625. #endif // EDITOR_PROPERTIES_H