editor_properties_vector.h 4.3 KB

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