editor_properties.h 26 KB

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