editor_properties.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  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. void set_secret(bool p_enabled);
  63. EditorPropertyText();
  64. };
  65. class EditorPropertyMultilineText : public EditorProperty {
  66. GDCLASS(EditorPropertyMultilineText, EditorProperty);
  67. TextEdit *text = nullptr;
  68. AcceptDialog *big_text_dialog = nullptr;
  69. TextEdit *big_text = nullptr;
  70. Button *open_big_text = nullptr;
  71. void _big_text_changed();
  72. void _text_changed();
  73. void _open_big_text();
  74. bool expression = false;
  75. protected:
  76. virtual void _set_read_only(bool p_read_only) override;
  77. void _notification(int p_what);
  78. static void _bind_methods();
  79. public:
  80. virtual void update_property() override;
  81. EditorPropertyMultilineText(bool p_expression = false);
  82. };
  83. class EditorPropertyTextEnum : public EditorProperty {
  84. GDCLASS(EditorPropertyTextEnum, EditorProperty);
  85. HBoxContainer *default_layout = nullptr;
  86. HBoxContainer *edit_custom_layout = nullptr;
  87. OptionButton *option_button = nullptr;
  88. Button *edit_button = nullptr;
  89. LineEdit *custom_value_edit = nullptr;
  90. Button *accept_button = nullptr;
  91. Button *cancel_button = nullptr;
  92. Vector<String> options;
  93. bool string_name = false;
  94. bool loose_mode = false;
  95. void _emit_changed_value(String p_string);
  96. void _option_selected(int p_which);
  97. void _edit_custom_value();
  98. void _custom_value_submitted(String p_value);
  99. void _custom_value_accepted();
  100. void _custom_value_cancelled();
  101. protected:
  102. virtual void _set_read_only(bool p_read_only) override;
  103. static void _bind_methods();
  104. void _notification(int p_what);
  105. public:
  106. void setup(const Vector<String> &p_options, bool p_string_name = false, bool p_loose_mode = false);
  107. virtual void update_property() override;
  108. EditorPropertyTextEnum();
  109. };
  110. class EditorPropertyPath : public EditorProperty {
  111. GDCLASS(EditorPropertyPath, EditorProperty);
  112. Vector<String> extensions;
  113. bool folder = false;
  114. bool global = false;
  115. bool save_mode = false;
  116. EditorFileDialog *dialog = nullptr;
  117. LineEdit *path = nullptr;
  118. Button *path_edit = nullptr;
  119. void _path_selected(const String &p_path);
  120. void _path_pressed();
  121. void _path_focus_exited();
  122. void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  123. bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  124. protected:
  125. virtual void _set_read_only(bool p_read_only) override;
  126. static void _bind_methods();
  127. void _notification(int p_what);
  128. public:
  129. void setup(const Vector<String> &p_extensions, bool p_folder, bool p_global);
  130. void set_save_mode();
  131. virtual void update_property() override;
  132. EditorPropertyPath();
  133. };
  134. class EditorPropertyLocale : public EditorProperty {
  135. GDCLASS(EditorPropertyLocale, EditorProperty);
  136. EditorLocaleDialog *dialog = nullptr;
  137. LineEdit *locale = nullptr;
  138. Button *locale_edit = nullptr;
  139. void _locale_selected(const String &p_locale);
  140. void _locale_pressed();
  141. void _locale_focus_exited();
  142. protected:
  143. static void _bind_methods();
  144. void _notification(int p_what);
  145. public:
  146. void setup(const String &p_hit_string);
  147. virtual void update_property() override;
  148. EditorPropertyLocale();
  149. };
  150. class EditorPropertyClassName : public EditorProperty {
  151. GDCLASS(EditorPropertyClassName, EditorProperty);
  152. private:
  153. CreateDialog *dialog = nullptr;
  154. Button *property = nullptr;
  155. String selected_type;
  156. String base_type;
  157. void _property_selected();
  158. void _dialog_created();
  159. protected:
  160. virtual void _set_read_only(bool p_read_only) override;
  161. static void _bind_methods();
  162. public:
  163. void setup(const String &p_base_type, const String &p_selected_type);
  164. virtual void update_property() override;
  165. EditorPropertyClassName();
  166. };
  167. class EditorPropertyMember : public EditorProperty {
  168. GDCLASS(EditorPropertyMember, EditorProperty);
  169. public:
  170. enum Type {
  171. MEMBER_METHOD_OF_VARIANT_TYPE, ///< a method of a type
  172. MEMBER_METHOD_OF_BASE_TYPE, ///< a method of a base type
  173. MEMBER_METHOD_OF_INSTANCE, ///< a method of an instance
  174. MEMBER_METHOD_OF_SCRIPT, ///< a method of a script & base
  175. MEMBER_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
  176. MEMBER_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
  177. MEMBER_PROPERTY_OF_INSTANCE, ///< a property of an instance
  178. MEMBER_PROPERTY_OF_SCRIPT, ///< a property of a script & base
  179. };
  180. private:
  181. Type hint;
  182. PropertySelector *selector = nullptr;
  183. Button *property = nullptr;
  184. String hint_text;
  185. void _property_selected(const String &p_selected);
  186. void _property_select();
  187. protected:
  188. virtual void _set_read_only(bool p_read_only) override;
  189. static void _bind_methods();
  190. public:
  191. void setup(Type p_hint, const String &p_hint_text);
  192. virtual void update_property() override;
  193. EditorPropertyMember();
  194. };
  195. class EditorPropertyCheck : public EditorProperty {
  196. GDCLASS(EditorPropertyCheck, EditorProperty);
  197. CheckBox *checkbox = nullptr;
  198. void _checkbox_pressed();
  199. protected:
  200. virtual void _set_read_only(bool p_read_only) override;
  201. static void _bind_methods();
  202. public:
  203. virtual void update_property() override;
  204. EditorPropertyCheck();
  205. };
  206. class EditorPropertyEnum : public EditorProperty {
  207. GDCLASS(EditorPropertyEnum, EditorProperty);
  208. OptionButton *options = nullptr;
  209. void _option_selected(int p_which);
  210. protected:
  211. virtual void _set_read_only(bool p_read_only) override;
  212. static void _bind_methods();
  213. public:
  214. void setup(const Vector<String> &p_options);
  215. virtual void update_property() override;
  216. void set_option_button_clip(bool p_enable);
  217. EditorPropertyEnum();
  218. };
  219. class EditorPropertyFlags : public EditorProperty {
  220. GDCLASS(EditorPropertyFlags, EditorProperty);
  221. VBoxContainer *vbox = nullptr;
  222. Vector<CheckBox *> flags;
  223. Vector<uint32_t> flag_values;
  224. void _flag_toggled(int p_index);
  225. protected:
  226. virtual void _set_read_only(bool p_read_only) override;
  227. static void _bind_methods();
  228. public:
  229. void setup(const Vector<String> &p_options);
  230. virtual void update_property() override;
  231. EditorPropertyFlags();
  232. };
  233. ///////////////////// LAYERS /////////////////////////
  234. class EditorPropertyLayersGrid : public Control {
  235. GDCLASS(EditorPropertyLayersGrid, Control);
  236. private:
  237. Vector<Rect2> flag_rects;
  238. Rect2 expand_rect;
  239. bool expand_hovered = false;
  240. bool expanded = false;
  241. int expansion_rows = 0;
  242. int hovered_index = -1;
  243. bool read_only = false;
  244. int renamed_layer_index = -1;
  245. PopupMenu *layer_rename = nullptr;
  246. ConfirmationDialog *rename_dialog = nullptr;
  247. LineEdit *rename_dialog_text = nullptr;
  248. void _rename_pressed(int p_menu);
  249. void _rename_operation_confirm();
  250. Size2 get_grid_size() const;
  251. protected:
  252. void _notification(int p_what);
  253. static void _bind_methods();
  254. public:
  255. uint32_t value = 0;
  256. int layer_group_size = 0;
  257. int layer_count = 0;
  258. Vector<String> names;
  259. Vector<String> tooltips;
  260. void set_read_only(bool p_read_only);
  261. virtual Size2 get_minimum_size() const override;
  262. virtual String get_tooltip(const Point2 &p_pos) const override;
  263. void gui_input(const Ref<InputEvent> &p_ev) override;
  264. void set_flag(uint32_t p_flag);
  265. EditorPropertyLayersGrid();
  266. };
  267. class EditorPropertyLayers : public EditorProperty {
  268. GDCLASS(EditorPropertyLayers, EditorProperty);
  269. public:
  270. enum LayerType {
  271. LAYER_PHYSICS_2D,
  272. LAYER_RENDER_2D,
  273. LAYER_NAVIGATION_2D,
  274. LAYER_PHYSICS_3D,
  275. LAYER_RENDER_3D,
  276. LAYER_NAVIGATION_3D,
  277. };
  278. private:
  279. EditorPropertyLayersGrid *grid = nullptr;
  280. void _grid_changed(uint32_t p_grid);
  281. String basename;
  282. LayerType layer_type;
  283. PopupMenu *layers = nullptr;
  284. TextureButton *button = nullptr;
  285. void _button_pressed();
  286. void _menu_pressed(int p_menu);
  287. void _refresh_names();
  288. protected:
  289. void _notification(int p_what);
  290. virtual void _set_read_only(bool p_read_only) override;
  291. static void _bind_methods();
  292. public:
  293. void setup(LayerType p_layer_type);
  294. void set_layer_name(int p_index, const String &p_name);
  295. String get_layer_name(int p_index) const;
  296. virtual void update_property() override;
  297. EditorPropertyLayers();
  298. };
  299. class EditorPropertyInteger : public EditorProperty {
  300. GDCLASS(EditorPropertyInteger, EditorProperty);
  301. EditorSpinSlider *spin = nullptr;
  302. bool setting = false;
  303. void _value_changed(int64_t p_val);
  304. protected:
  305. virtual void _set_read_only(bool p_read_only) override;
  306. static void _bind_methods();
  307. public:
  308. virtual void update_property() override;
  309. void setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix = String());
  310. EditorPropertyInteger();
  311. };
  312. class EditorPropertyObjectID : public EditorProperty {
  313. GDCLASS(EditorPropertyObjectID, EditorProperty);
  314. Button *edit = nullptr;
  315. String base_type;
  316. void _edit_pressed();
  317. protected:
  318. virtual void _set_read_only(bool p_read_only) override;
  319. static void _bind_methods();
  320. public:
  321. virtual void update_property() override;
  322. void setup(const String &p_base_type);
  323. EditorPropertyObjectID();
  324. };
  325. class EditorPropertySignal : public EditorProperty {
  326. GDCLASS(EditorPropertySignal, EditorProperty);
  327. Button *edit = nullptr;
  328. String base_type;
  329. void _edit_pressed();
  330. protected:
  331. static void _bind_methods();
  332. public:
  333. virtual void update_property() override;
  334. EditorPropertySignal();
  335. };
  336. class EditorPropertyCallable : public EditorProperty {
  337. GDCLASS(EditorPropertyCallable, EditorProperty);
  338. Button *edit = nullptr;
  339. String base_type;
  340. protected:
  341. static void _bind_methods();
  342. public:
  343. virtual void update_property() override;
  344. EditorPropertyCallable();
  345. };
  346. class EditorPropertyFloat : public EditorProperty {
  347. GDCLASS(EditorPropertyFloat, EditorProperty);
  348. EditorSpinSlider *spin = nullptr;
  349. bool setting = false;
  350. bool angle_in_radians = false;
  351. void _value_changed(double p_val);
  352. protected:
  353. virtual void _set_read_only(bool p_read_only) override;
  354. static void _bind_methods();
  355. public:
  356. virtual void update_property() override;
  357. 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);
  358. EditorPropertyFloat();
  359. };
  360. class EditorPropertyEasing : public EditorProperty {
  361. GDCLASS(EditorPropertyEasing, EditorProperty);
  362. Control *easing_draw = nullptr;
  363. PopupMenu *preset = nullptr;
  364. EditorSpinSlider *spin = nullptr;
  365. bool setting = false;
  366. bool dragging = false;
  367. bool full = false;
  368. bool flip = false;
  369. bool positive_only = false;
  370. enum {
  371. EASING_ZERO,
  372. EASING_LINEAR,
  373. EASING_IN,
  374. EASING_OUT,
  375. EASING_IN_OUT,
  376. EASING_OUT_IN,
  377. EASING_MAX
  378. };
  379. void _drag_easing(const Ref<InputEvent> &p_ev);
  380. void _draw_easing();
  381. void _set_preset(int);
  382. void _setup_spin();
  383. void _spin_value_changed(double p_value);
  384. void _spin_focus_exited();
  385. void _notification(int p_what);
  386. protected:
  387. virtual void _set_read_only(bool p_read_only) override;
  388. static void _bind_methods();
  389. public:
  390. virtual void update_property() override;
  391. void setup(bool p_positive_only, bool p_flip);
  392. EditorPropertyEasing();
  393. };
  394. class EditorPropertyVector2 : public EditorProperty {
  395. GDCLASS(EditorPropertyVector2, EditorProperty);
  396. EditorSpinSlider *spin[2];
  397. bool setting = false;
  398. double ratio_xy = 1.0;
  399. double ratio_yx = 1.0;
  400. TextureButton *linked = nullptr;
  401. void _update_ratio();
  402. void _value_changed(double p_val, const String &p_name);
  403. protected:
  404. virtual void _set_read_only(bool p_read_only) override;
  405. void _notification(int p_what);
  406. public:
  407. virtual void update_property() override;
  408. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link = false, const String &p_suffix = String());
  409. EditorPropertyVector2(bool p_force_wide = false);
  410. };
  411. class EditorPropertyRect2 : public EditorProperty {
  412. GDCLASS(EditorPropertyRect2, EditorProperty);
  413. EditorSpinSlider *spin[4];
  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(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  423. EditorPropertyRect2(bool p_force_wide = false);
  424. };
  425. class EditorPropertyVector3 : public EditorProperty {
  426. GDCLASS(EditorPropertyVector3, EditorProperty);
  427. EditorSpinSlider *spin[3];
  428. bool setting = false;
  429. bool angle_in_radians = false;
  430. double ratio_yx = 1.0;
  431. double ratio_zx = 1.0;
  432. double ratio_xy = 1.0;
  433. double ratio_zy = 1.0;
  434. double ratio_xz = 1.0;
  435. double ratio_yz = 1.0;
  436. TextureButton *linked = nullptr;
  437. void _update_ratio();
  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. virtual void update_using_vector(Vector3 p_vector);
  446. virtual Vector3 get_vector();
  447. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link = false, const String &p_suffix = String(), bool p_angle_in_radians = false);
  448. EditorPropertyVector3(bool p_force_wide = false);
  449. };
  450. class EditorPropertyVector2i : public EditorProperty {
  451. GDCLASS(EditorPropertyVector2i, EditorProperty);
  452. EditorSpinSlider *spin[2];
  453. bool setting = false;
  454. double ratio_xy = 1.0;
  455. double ratio_yx = 1.0;
  456. TextureButton *linked = nullptr;
  457. void _update_ratio();
  458. void _value_changed(double p_val, const String &p_name);
  459. protected:
  460. virtual void _set_read_only(bool p_read_only) override;
  461. void _notification(int p_what);
  462. public:
  463. virtual void update_property() override;
  464. void setup(int p_min, int p_max, bool p_hide_slider, bool p_link = false, const String &p_suffix = String());
  465. EditorPropertyVector2i(bool p_force_wide = false);
  466. };
  467. class EditorPropertyRect2i : public EditorProperty {
  468. GDCLASS(EditorPropertyRect2i, 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(int p_min, int p_max, bool p_hide_slider, const String &p_suffix = String());
  479. EditorPropertyRect2i(bool p_force_wide = false);
  480. };
  481. class EditorPropertyVector3i : public EditorProperty {
  482. GDCLASS(EditorPropertyVector3i, EditorProperty);
  483. EditorSpinSlider *spin[3];
  484. bool setting = false;
  485. double ratio_yx = 1.0;
  486. double ratio_zx = 1.0;
  487. double ratio_xy = 1.0;
  488. double ratio_zy = 1.0;
  489. double ratio_xz = 1.0;
  490. double ratio_yz = 1.0;
  491. TextureButton *linked = nullptr;
  492. void _update_ratio();
  493. void _value_changed(double p_val, const String &p_name);
  494. protected:
  495. virtual void _set_read_only(bool p_read_only) override;
  496. void _notification(int p_what);
  497. static void _bind_methods();
  498. public:
  499. virtual void update_property() override;
  500. void setup(int p_min, int p_max, bool p_hide_slider, bool p_link = false, const String &p_suffix = String());
  501. EditorPropertyVector3i(bool p_force_wide = false);
  502. };
  503. class EditorPropertyPlane : public EditorProperty {
  504. GDCLASS(EditorPropertyPlane, EditorProperty);
  505. EditorSpinSlider *spin[4];
  506. bool setting = false;
  507. void _value_changed(double p_val, const String &p_name);
  508. protected:
  509. virtual void _set_read_only(bool p_read_only) override;
  510. void _notification(int p_what);
  511. static void _bind_methods();
  512. public:
  513. virtual void update_property() override;
  514. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  515. EditorPropertyPlane(bool p_force_wide = false);
  516. };
  517. class EditorPropertyQuaternion : public EditorProperty {
  518. GDCLASS(EditorPropertyQuaternion, EditorProperty);
  519. BoxContainer *default_layout = nullptr;
  520. EditorSpinSlider *spin[4];
  521. bool setting = false;
  522. Button *warning = nullptr;
  523. AcceptDialog *warning_dialog = nullptr;
  524. Label *euler_label = nullptr;
  525. VBoxContainer *edit_custom_bc = nullptr;
  526. EditorSpinSlider *euler[3];
  527. Button *edit_button = nullptr;
  528. Vector3 edit_euler = Vector3();
  529. void _value_changed(double p_val, const String &p_name);
  530. void _edit_custom_value();
  531. void _custom_value_changed(double p_val);
  532. void _warning_pressed();
  533. bool is_grabbing_euler();
  534. protected:
  535. virtual void _set_read_only(bool p_read_only) override;
  536. void _notification(int p_what);
  537. static void _bind_methods();
  538. public:
  539. virtual void update_property() override;
  540. 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);
  541. EditorPropertyQuaternion();
  542. };
  543. class EditorPropertyVector4 : public EditorProperty {
  544. GDCLASS(EditorPropertyVector4, EditorProperty);
  545. EditorSpinSlider *spin[4];
  546. bool setting = false;
  547. void _value_changed(double p_val, const String &p_name);
  548. protected:
  549. virtual void _set_read_only(bool p_read_only) override;
  550. void _notification(int p_what);
  551. static void _bind_methods();
  552. public:
  553. virtual void update_property() override;
  554. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  555. EditorPropertyVector4();
  556. };
  557. class EditorPropertyVector4i : public EditorProperty {
  558. GDCLASS(EditorPropertyVector4i, EditorProperty);
  559. EditorSpinSlider *spin[4];
  560. bool setting = false;
  561. void _value_changed(double p_val, const String &p_name);
  562. protected:
  563. virtual void _set_read_only(bool p_read_only) override;
  564. void _notification(int p_what);
  565. static void _bind_methods();
  566. public:
  567. virtual void update_property() override;
  568. void setup(double p_min, double p_max, bool p_hide_slider, const String &p_suffix = String());
  569. EditorPropertyVector4i();
  570. };
  571. class EditorPropertyAABB : public EditorProperty {
  572. GDCLASS(EditorPropertyAABB, EditorProperty);
  573. EditorSpinSlider *spin[6];
  574. bool setting = false;
  575. void _value_changed(double p_val, const String &p_name);
  576. protected:
  577. virtual void _set_read_only(bool p_read_only) override;
  578. void _notification(int p_what);
  579. static void _bind_methods();
  580. public:
  581. virtual void update_property() override;
  582. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  583. EditorPropertyAABB();
  584. };
  585. class EditorPropertyTransform2D : public EditorProperty {
  586. GDCLASS(EditorPropertyTransform2D, EditorProperty);
  587. EditorSpinSlider *spin[6];
  588. bool setting = false;
  589. void _value_changed(double p_val, const String &p_name);
  590. protected:
  591. virtual void _set_read_only(bool p_read_only) override;
  592. void _notification(int p_what);
  593. static void _bind_methods();
  594. public:
  595. virtual void update_property() override;
  596. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  597. EditorPropertyTransform2D(bool p_include_origin = true);
  598. };
  599. class EditorPropertyBasis : public EditorProperty {
  600. GDCLASS(EditorPropertyBasis, EditorProperty);
  601. EditorSpinSlider *spin[9];
  602. bool setting = false;
  603. void _value_changed(double p_val, const String &p_name);
  604. protected:
  605. virtual void _set_read_only(bool p_read_only) override;
  606. void _notification(int p_what);
  607. static void _bind_methods();
  608. public:
  609. virtual void update_property() override;
  610. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  611. EditorPropertyBasis();
  612. };
  613. class EditorPropertyTransform3D : public EditorProperty {
  614. GDCLASS(EditorPropertyTransform3D, EditorProperty);
  615. EditorSpinSlider *spin[12];
  616. bool setting = false;
  617. void _value_changed(double p_val, const String &p_name);
  618. protected:
  619. virtual void _set_read_only(bool p_read_only) override;
  620. void _notification(int p_what);
  621. static void _bind_methods();
  622. public:
  623. virtual void update_property() override;
  624. virtual void update_using_transform(Transform3D p_transform);
  625. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  626. EditorPropertyTransform3D();
  627. };
  628. class EditorPropertyProjection : public EditorProperty {
  629. GDCLASS(EditorPropertyProjection, EditorProperty);
  630. EditorSpinSlider *spin[16];
  631. bool setting = false;
  632. void _value_changed(double p_val, const String &p_name);
  633. protected:
  634. virtual void _set_read_only(bool p_read_only) override;
  635. void _notification(int p_what);
  636. static void _bind_methods();
  637. public:
  638. virtual void update_property() override;
  639. virtual void update_using_transform(Projection p_transform);
  640. void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
  641. EditorPropertyProjection();
  642. };
  643. class EditorPropertyColor : public EditorProperty {
  644. GDCLASS(EditorPropertyColor, EditorProperty);
  645. ColorPickerButton *picker = nullptr;
  646. void _color_changed(const Color &p_color);
  647. void _popup_closed();
  648. void _picker_created();
  649. void _picker_opening();
  650. Color last_color;
  651. protected:
  652. virtual void _set_read_only(bool p_read_only) override;
  653. void _notification(int p_what);
  654. public:
  655. virtual void update_property() override;
  656. void setup(bool p_show_alpha);
  657. EditorPropertyColor();
  658. };
  659. class EditorPropertyNodePath : public EditorProperty {
  660. GDCLASS(EditorPropertyNodePath, EditorProperty);
  661. Button *assign = nullptr;
  662. Button *clear = nullptr;
  663. SceneTreeDialog *scene_tree = nullptr;
  664. NodePath base_hint;
  665. bool use_path_from_scene_root = false;
  666. bool pointer_mode = false;
  667. Vector<StringName> valid_types;
  668. void _node_selected(const NodePath &p_path);
  669. void _node_assign();
  670. void _node_clear();
  671. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  672. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  673. bool is_drop_valid(const Dictionary &p_drag_data) const;
  674. String _get_meta_pointer_property() const;
  675. virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const override;
  676. virtual StringName _get_revert_property() const override;
  677. protected:
  678. virtual void _set_read_only(bool p_read_only) override;
  679. static void _bind_methods();
  680. void _notification(int p_what);
  681. public:
  682. virtual void update_property() override;
  683. void setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root = true, bool p_pointer_mode = false);
  684. EditorPropertyNodePath();
  685. };
  686. class EditorPropertyRID : public EditorProperty {
  687. GDCLASS(EditorPropertyRID, EditorProperty);
  688. Label *label = nullptr;
  689. public:
  690. virtual void update_property() override;
  691. EditorPropertyRID();
  692. };
  693. class EditorPropertyResource : public EditorProperty {
  694. GDCLASS(EditorPropertyResource, EditorProperty);
  695. EditorResourcePicker *resource_picker = nullptr;
  696. SceneTreeDialog *scene_tree = nullptr;
  697. bool use_sub_inspector = false;
  698. EditorInspector *sub_inspector = nullptr;
  699. VBoxContainer *sub_inspector_vbox = nullptr;
  700. bool updating_theme = false;
  701. bool opened_editor = false;
  702. void _resource_selected(const Ref<Resource> &p_resource, bool p_inspect);
  703. void _resource_changed(const Ref<Resource> &p_resource);
  704. void _viewport_selected(const NodePath &p_path);
  705. void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance);
  706. void _sub_inspector_resource_selected(const Ref<Resource> &p_resource, const String &p_property);
  707. void _sub_inspector_object_id_selected(int p_id);
  708. void _open_editor_pressed();
  709. void _fold_other_editors(Object *p_self);
  710. void _update_property_bg();
  711. void _update_preferred_shader();
  712. protected:
  713. virtual void _set_read_only(bool p_read_only) override;
  714. static void _bind_methods();
  715. void _notification(int p_what);
  716. public:
  717. virtual void update_property() override;
  718. void setup(Object *p_object, const String &p_path, const String &p_base_type);
  719. void collapse_all_folding() override;
  720. void expand_all_folding() override;
  721. void expand_revertable() override;
  722. void set_use_sub_inspector(bool p_enable);
  723. EditorPropertyResource();
  724. };
  725. ///////////////////////////////////////////////////
  726. /// \brief The EditorInspectorDefaultPlugin class
  727. ///
  728. class EditorInspectorDefaultPlugin : public EditorInspectorPlugin {
  729. GDCLASS(EditorInspectorDefaultPlugin, EditorInspectorPlugin);
  730. public:
  731. virtual bool can_handle(Object *p_object) override;
  732. 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;
  733. 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);
  734. };
  735. #endif // EDITOR_PROPERTIES_H