editor_properties_vector.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**************************************************************************/
  2. /* editor_properties_vector.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_VECTOR_H
  31. #define EDITOR_PROPERTIES_VECTOR_H
  32. #include "editor/editor_inspector.h"
  33. class EditorSpinSlider;
  34. class TextureButton;
  35. class EditorPropertyVectorN : public EditorProperty {
  36. GDCLASS(EditorPropertyVectorN, EditorProperty);
  37. static const String COMPONENT_LABELS[4];
  38. int component_count = 0;
  39. Variant::Type vector_type;
  40. Vector<EditorSpinSlider *> spin_sliders;
  41. TextureButton *linked = nullptr;
  42. Vector<double> ratio;
  43. bool is_grabbed = false;
  44. bool radians_as_degrees = false;
  45. void _update_ratio();
  46. void _store_link(bool p_linked);
  47. void _grab_changed(bool p_grab);
  48. void _value_changed(double p_val, const String &p_name);
  49. protected:
  50. virtual void _set_read_only(bool p_read_only) override;
  51. void _notification(int p_what);
  52. public:
  53. virtual void update_property() override;
  54. void setup(double p_min, double p_max, double p_step = 1.0, bool p_hide_slider = true, bool p_link = false, const String &p_suffix = String(), bool p_radians_as_degrees = false);
  55. EditorPropertyVectorN(Variant::Type p_type, bool p_force_wide, bool p_horizontal);
  56. };
  57. class EditorPropertyVector2 : public EditorPropertyVectorN {
  58. GDCLASS(EditorPropertyVector2, EditorPropertyVectorN);
  59. public:
  60. EditorPropertyVector2(bool p_force_wide = false);
  61. };
  62. class EditorPropertyVector2i : public EditorPropertyVectorN {
  63. GDCLASS(EditorPropertyVector2i, EditorPropertyVectorN);
  64. public:
  65. EditorPropertyVector2i(bool p_force_wide = false);
  66. };
  67. class EditorPropertyVector3 : public EditorPropertyVectorN {
  68. GDCLASS(EditorPropertyVector3, EditorPropertyVectorN);
  69. public:
  70. EditorPropertyVector3(bool p_force_wide = false);
  71. };
  72. class EditorPropertyVector3i : public EditorPropertyVectorN {
  73. GDCLASS(EditorPropertyVector3i, EditorPropertyVectorN);
  74. public:
  75. EditorPropertyVector3i(bool p_force_wide = false);
  76. };
  77. class EditorPropertyVector4 : public EditorPropertyVectorN {
  78. GDCLASS(EditorPropertyVector4, EditorPropertyVectorN);
  79. public:
  80. EditorPropertyVector4(bool p_force_wide = false);
  81. };
  82. class EditorPropertyVector4i : public EditorPropertyVectorN {
  83. GDCLASS(EditorPropertyVector4i, EditorPropertyVectorN);
  84. public:
  85. EditorPropertyVector4i(bool p_force_wide = false);
  86. };
  87. #endif // EDITOR_PROPERTIES_VECTOR_H