editor_properties.h 26 KB

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